Character turning in the camera direction Author Message
SamNainocard
Bronze Supporter

 Post: #16 RE: Character turning in the camera direction Never known that AngleDelta is even more simple, cool.
05-13-2013 05:22 AM
Kiekos
Member

 Post: #17 RE: Character turning in the camera direction @Esenthel, thanks for the solution. However I still have problem with character turning akwardly when I want to pass -PI and PI border. Maybe this drawing will help understand the problem: Character is facing the way the green line shows (S & A pressed). I want him to turn to the direction where the orange line is (S & D pressed). Instead of going the way the red line shows (turning 90°), he turnes the way the purple line shows (270°)... Still haven't figured out how to solve it.
05-13-2013 03:01 PM
SamNainocard
Bronze Supporter

 Post: #18 RE: Character turning in the camera direction I guess, it's something wrong with Cam.yaw +/- PI stuff. Try changing formula. Something like PHP Code: `cam_yaw=Cam.yaw + PI_2;   // Acam_yaw=Cam.yaw - PI_2;   // D ` Something like left side use + while right side use -. (This post was last modified: 05-16-2013 11:52 AM by SamNainocard.)
05-16-2013 11:48 AM
Kiekos
Member

 Post: #19 RE: Character turning in the camera direction A set of golden shovels for me for digging this post out after half a year lol: I still haven't figured out the problem I've described in post #17 (2UP) and provided and image. I know where the problem is but I don't know how to solve it. I've drawn hundreds of sketches hoping to come up with some idea but naaah... The green line is Cam.yaw + 3/4*PI and the orange line Cam.yaw - 3/4*PI. I want the character to turn 90 degrees but he turns 270 degrees because that's the way Lerp works. In this case it starts to decrease the value until it reaches the desired value, so it goes from Cam.yaw + 3/4*PI to Cam.yaw - 3/4*PI through Cam.yaw which is 0 degrees. It simply won't cross the +PI / -PI border no matter what... How can I make my way around that issue? (This post was last modified: 11-24-2013 02:29 AM by Kiekos.)
11-24-2013 02:23 AM
Esenthel

 Post: #20 RE: Character turning in the camera direction (11-24-2013 02:23 AM)Kiekos Wrote:  I want the character to turn 90 degrees but he turns 270 degrees because that's the way Lerp works. Please look into 'LerpAngle' which workarounds this
11-25-2013 04:41 AM
Kiekos
Member

 Post: #21 RE: Character turning in the camera direction Well... 6 months of trying to deal with a problem and it was that simple. Clumsy me, thanks Esenthel
11-25-2013 06:54 PM
Palaxe
Member

 Post: #22 RE: Character turning in the camera direction Well here is what I did with MMO, This is like Wow movement you can pan around and then when you hold both mouse buttons down the character goes foward, But when you run backward he faces you. I don't know if that helps. Code: ```if(!action)     {               input.move.z=Kb.b(KB_W)+(Ms.b(0) && Ms.b(1))+Kb.b(KB_A)+Kb.b(KB_D)+Kb.b(KB_S);            }    if (Kb.b(KB_W))        angle.x = Cam.yaw;           if (Ms.b(1) && Ms.b(0))        angle.x = Cam.yaw;    if (Kb.b(KB_S))        angle.x = Cam.yaw + PI;    if (Kb.b(KB_A))        angle.x = Cam.yaw + PI_2;    if (Kb.b(KB_D))        angle.x = Cam.yaw - PI_2;    if (Kb.b(KB_W) && Kb.b(KB_A))        angle.x = Cam.yaw + PI_4;    if (Kb.b(KB_W) && Kb.b(KB_D))        angle.x = Cam.yaw - PI_4;    if (Kb.b(KB_S) && Kb.b(KB_A))        angle.x = Cam.yaw + PI - PI_4;    if (Kb.b(KB_S) && Kb.b(KB_D))        angle.x = Cam.yaw + PI + PI_4;               input.jump  =(Kb.bp(KB_SPACE ) ? 3.5 : 0);``` (This post was last modified: 11-26-2013 05:08 AM by Palaxe.)
11-26-2013 05:07 AM
 « Next Oldest | Next Newest »