About Store Forum Documentation Contact



Post Reply 
Character turning in the camera direction
Author Message
SamNainocard Offline
Member

Post: #16
RE: Character turning in the camera direction
Never known that AngleDelta is even more simple, cool.
05-13-2013 05:22 AM
Find all posts by this user Quote this message in a reply
Kiekos Offline
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:

[Image: jmhtSNI.png]

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
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

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;   // A
cam_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
Find all posts by this user Quote this message in a reply
Kiekos Offline
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:

[Image: UHhvYQE.jpg]

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
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

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
Find all posts by this user Quote this message in a reply
Kiekos Offline
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 smile
11-25-2013 06:54 PM
Find all posts by this user Quote this message in a reply
Palaxe Offline
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
Find all posts by this user Quote this message in a reply
Post Reply