- Home /
Speed of player depends on angle of rotation
Hi!
I'm currently working on a new project of mine which is a skiing game. I want my player to move at max speed when they are facing straight down or up (going backwards) along the y-axis. If they are facing right or left their speed should be 0. Essentially the more they are facing downhill the faster they go forward giving the illusion of gravity since it is just on a flat plane.
Been scratching my head on this for quite a while and haven't got anything solid. I've provided a diagram of what I mean if that helps. Any advice welcome
Answer by kristianpayne1 · Aug 22, 2019 at 11:23 PM
Solved it using Vector3.Dot() !
float downhillPower = Mathf.Abs(Vector3.Dot(transform.forward, Vector3.forward));
Your answer
Follow this Question
Related Questions
Curve player movement 1 Answer
Speed limit? 2 Answers
Add Force to the right of the rigidbody, not right of the screen 1 Answer
Rotation strange 1 Answer
Make an object move to a given point by rotating to the correct direction first. 1 Answer