Game Development Community

Player Yaw & Pitch explicit

by Jonathan Smelquist · in Torque Game Engine · 09/16/2006 (4:40 pm) · 8 replies

Could anyone point me in the right direction for explicitly telling the player object where to look? $mvYaw and $mvPitch use increments to change the position where i just simply want to match the camera to the direct back of the player whenever the right-mouse-button is down. i am using advanced orbit camera and an interface mod to allow for onrightmousedrag events and such. I have played with trying to adjust the players Yaw in sync with the camera but it does not give the desired effect.

F32 cameraYawSpeed = Con::getFloatVariable( "$cameraYawSpeed");
Con::setFloatVariable( "$advCamera::Yaw", diff.x * cameraYawSpeed);
Con::setFloatVariable( "$mvYaw", ((diff.x * cameraYawSpeed)/1250)*-1);

is what i currently do and it sort of works, but as you can probably tell, it will get out of sync.

Is there a way i can expose the actual Yaw value of the player instead of $mvyaw? or is there an even simpler way of syncing the players view with the cameras view?

Jon

#1
06/07/2009 (2:23 am)
I think this sounds like exactly what I am trying to do. Did you figure it out?
#2
06/07/2009 (3:39 am)
You are out of sync,because you have wrong advancing.
You advance according to time,which is wrong.
And you will get different results on different hardware.

You should advance,according to 1/fps (dt).

In advanced camera code,there is a method,named updateMovementValues();
It is the key to understand the problem.
#3
06/07/2009 (3:47 am)
@Peter: $mvYaw is the incremental change applied to a player's rotation each frame, so to set that value explicitly you'd most likely need to make some engine changes. You might be able to get by using setTransform, but personally I'd add a mvExactYaw variable to the moveManager class. Then you can handle rotations differently in GameConnection::getNextMove depending on whether you need an incremental change or an explicit one. This has the added benefit of being networked, unlike just setting mRot.z in the player class, for instance.
#4
06/07/2009 (4:12 am)
@Mike: I saw your reply here too:
www.garagegames.com/community/forums/viewthread/74902

Yes, I am trying to do 8-way directional movement, such that move forward moves the character forward relative to the current advanced camera's looking-at direction. Move down is 180 degrees (PI radians) away. 0 45 90 135 180 235 270 315: 8-way directional movement

Hmm, being new to torque so far, I guess I don't really have a clue about how the torque networking stuff is organized and this networked vs. non-networked issue. Sounds like you're saying my use of setTransform is not good because it's not networked, or not networked good enough...
#5
06/07/2009 (4:19 am)
I'm pretty sure any changes with setTransform will be sent to other clients--and I'm not saying setTransform won't work, or won't work well. The way that resource I linked does it has just always been the way I've made movement code changes for my top-down shooters and such. Then again, my top-down shooters need aim and movement to be independent of one another (i.e. you can hit 'A' to move west while shooting south), so setTransform would probably work if you don't need a similar control scheme.
#6
06/07/2009 (4:38 am)
Hm, so I guess you could have 3 separate/independent rotations:
A1) camera angle orbit around the player
A2) player aim direction
A3) player movement directions

...

For what I'm trying to do, I'm basically trying to extend Diablo-style movement by:
B1) making it more 3d, by letting you orbit around the player using keys Q and E
B2) allow keyboard movement based on the orbit angle

Starting with advanced camera god view mode, but seems like I may end up using orbit view mode instead... Otherwise, it would be B2 without B1.
#7
06/07/2009 (4:47 am)
Advanced Camera in Orbit Mode would definitely be the best way to go. Then you can just either use your setTransform code or implement the resource in my other post to move the player based on the camera's direction.
#8
06/07/2009 (10:55 pm)
Btw, I posted some comments here about my progress:
www.garagegames.com/community/resource/view/5474/3#comments

Currently works with Advanced Camera god mode view, but only for 0 to PI (ie, my character won't walk left).