- Home /
Inertia when running
Hello,
i'm using a character controller and i'd like to add an inertia if the direction change is too brutal.
Hereis my deplacement code public void UpdateDirection(Vector3 dir) { var cameraAngle = this.cameraReferential.rotation; this.cameraReferential.eulerAngles = new Vector3(0,this.cameraReferential.eulerAngles.y,0); dir = this.cameraReferential.rotation * dir; this.cameraReferential.rotation = cameraAngle; this.direction = dir * this.speed; }
the problem is the fact that Vector3.Angle doesn't send the value i'm expecting. I'd like to do something like if (Vector3.Angle(OldDirection, newDirection) > 180 { // Do some inertia and play animations }
But i actually can't get it to work and this is kind of frustrating. If you have any idea of how i could get the orientation i have before switching direction and the new one and comparate both in a reliable way (because Vector.Angle doesn't, or i'm using it wrong, i don't know)
then i think i could do the rest by myself or maybe a bit of indication of how apply actual inertia would be great.
Thanks a lot!