Dev. Question How to change player orientation?

Talk about anything related to Unvanquished.
Post Reply
vitamins
Posts: 11
Joined: Tue Dec 29, 2015 11:46 am UTC

Dev. Question How to change player orientation?

Post by vitamins »

Hi,
here's a question that i hope will get me started on working with unvanquished.

I would like to do the same thing that happens when the player is moving the mouse, using a function from the code:
change the direction in which the crosshair is pointing
change the direction in which the player is shooting(and walking) in the same way
Input: delta pitch and delta yaw as angles
So the experience for the user would be like someone else moved the mouse for a bit. The change can be undone by a player by moving the mouse in the opposite direction.
Finally, i would like to do this at each frame in a function that has access to an absolute time in miliseconds, to make it a smooth movement that lasts for a certain time.

User avatar
Ishq
Project Head
Posts: 1145
Joined: Tue Mar 06, 2012 8:32 pm UTC

Re: Dev. Question How to change player orientation?

Post by Ishq »

For examples of manipulating how players move and their view angles, look at https://github.com/Unvanquished/Unvanqu ... _pmove.cpp

playerState_t::delta_angles will move the player's view if you increment it. As for making them move, you want to replicate the walking PMove code path.

vitamins
Posts: 11
Joined: Tue Dec 29, 2015 11:46 am UTC

Re: Dev. Question How to change player orientation?

Post by vitamins »

Ishq wrote:

playerState_t::delta_angles will move the player's view if you increment it.

This is what i was looking for, and it works well, thanks. An other information i found out: You have a different range of values for delta_angles than for viewangles, and you have to use the ANGLE2SHORT and SHORT2ANGLE macros to convert between them.

I have two more questions, which are somewhat unrelated, in general, should i make a new thread for that? I'm continuing here for now.

  1. Where do i save playerstate variables which don't have to be transmitted over the network, because they are calculated from the other playerstate variables? Is everything i add to playerstate->xy transmitted over the network?

  2. In the bg_*.cpp files, is it possible to use absolute time instead of last frametime? Or do i have to decrement a time-counter by the last frametime at each frame, to count the passed time? For example, the weaponTime variable uses the latter method.

User avatar
Ishq
Project Head
Posts: 1145
Joined: Tue Mar 06, 2012 8:32 pm UTC

Re: Dev. Question How to change player orientation?

Post by Ishq »

Currently, yes. Hopefully though, this won't be the case with our new CBSE architecture. We're in the process of rewriting the gamelogic to take advantage of this. PMove has not been ported yet, however. For time I suppose it is possible. I'm not sure how well it would work because i haven't tried it though.

abbaa1234
Posts: 1
Joined: Wed Mar 16, 2016 6:55 am UTC

Re: Dev. Question How to change player orientation?

Post by abbaa1234 »

:smile:

Post Reply