- Home /
Add velocity relative to ground?
Let's say our player is on a flat surface. If we want to move the player, we add to the x and z components of the velocity. Now, what if the player is on a sloped surface? How would I transform the acceleration vector to be parallel with the plane that is the surface below? Thanks.
Answer by tormentoarmagedoom · Apr 08, 2018 at 09:12 PM
Good day.
You should use Vector3.Project in order to progect a vector over another.
But can i ask why you need this? Is for player movement? Why dont use NavMeshSystem?
Bye!
I was surprised this worked. I found the contact normal when the collision entered and stored it. I stored all the ground collisions and found the one with the greatest angle and proceeded to store it's normal. I projected the acceleration vector onto the plane with this normal using Vector3.ProjectOnPlane(). And I needed this because I am writing my own character controller as I greatly dislike the provided one; it looks all about done! Thanks :)
Your answer
Follow this Question
Related Questions
When I try to save the velocity of a rigidbody and use it later it doesn't work? 1 Answer
Speed based on distance 1 Answer
Rigidbody character controller can't walk on stairs 0 Answers
Velocity powered rigidbody on a moving platform without parenting. 3 Answers
strange unrealisticly physic problems about velocity/gravity acceleration 2 Answers