Question by
Vortavasail · Sep 05, 2016 at 12:29 AM ·
rotationspeedworldspacelocal spacelocal velocity
trying to get local forward and side to side values
transform.InverseTransformDirection (rb.velocity); this gives me rotational values ( numbers only change when i rotate the charter transform.InverseTransformDirection (rb.velocity. magnitude); this gives me a float that goes up and down even if i do nothing at all 0.xxxx to 7.xxxx values
and when i turn left right or backwards i animation slows down and dose not play using this its as if i cant
void anim_move () {
velocity = ((transform.forward - previous).magnitude) / Time.deltaTime;
// up down y this is not used yet but i will think of somthing
UDVelocity = ((transform.forward.y - previous.y)) / Time.deltaTime;
// back forward z
FBVelocity = ((transform.forward.z - previous.z)) / Time.deltaTime;
// left right x
LRVelocity = ((transform.forward.x - previous.x)) / Time.deltaTime;
rotaion = gameObject.transform.localRotation.eulerAngles.y;
rotaion = (rotaion > 180) ? rotaion - 360 : rotaion;
// this flips the singe so when changing walking directions.
#region failed attempts to try and fix walking back words if turn around form the starting position i walking animation is not played.
if ( rotaion < 0 ) {
float fliprot = FBVelocity * -1f;
anim.SetFloat ("Forward" , fliprot);
} else {
anim.SetFloat ("Forward" , FBVelocity);
}
#endregion
anim.SetFloat ("Right" , LRVelocity);
previous = transform.forward;
}
its as if i'm only reading world space witch i'm sure is the problem but all attempts to read local space fails.
i'm trying to get local speed values forward back left and right up and down and forward is always the way the game object is facing , and pass that info to the animator... i cant seem to get it to work.
Comment