Rigidbody is installed on the player. Is it possible somehow through the script to check whether the player is sliding along the slope at the moment?
1 answer
If your physics is properly configured, you can simply check its speed:
Debug.Log(rigidBody.velocity.magnitude > 0); If the length of the velocity vector is not 0, then the object is moving.
If in your game the object can move not only down the slope, it can be made even simpler: you need to check only the y component of speed:
Debug.Log(rigidBody.velocity.y < 0); It is less than 0, because when descending from a slope, the object moves down along the y axis.
- Thank you very much - Anton Tereshkin
- @ AntonTereshkin, the best thanks to the “correct answer” mark :) - RiotBr3aker
|