Page 1 of 1

Dev. Question How to change player orientation?

Posted: Tue Dec 29, 2015 12:59 pm UTC
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.

Re: Dev. Question How to change player orientation?

Posted: Tue Dec 29, 2015 1:17 pm UTC
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.

Re: Dev. Question How to change player orientation?

Posted: Wed Dec 30, 2015 10:37 pm UTC
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.

Re: Dev. Question How to change player orientation?

Posted: Thu Dec 31, 2015 12:03 pm UTC
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.

Re: Dev. Question How to change player orientation?

Posted: Wed Mar 16, 2016 6:56 am UTC
by abbaa1234
:smile: