Answer the question
In order to leave comments, you need to log in
How can one read and record vector changes (jump and fall)?
Good night, I want to make an animation of a jump and a fall, I didn’t find anything worthwhile on the Internet, I deal with the demo from the unit.
So far I came to the conclusion that I have 2 jump and fall animations, I added them and made the float parameter in the animator
Here's how to make this value change when I jump, for example, it will be 1 and when I start to fall, 0
I don't ask you to write a full script for me at least a piece of the change itself from 1 to 0, since I still don’t rummage much :)
Answer the question
In order to leave comments, you need to log in
If I understood your question correctly, you just need to find out at what moment the character jumps and at what moment he falls.
In my project, the jump and fall were calculated by the Rigidbody, i.e. I set the height of the jump using the force vector. The Rigidbody component has a velocity property that reflects the direction of movement. Therefore, when the player is in a jump state (flying up), velocity.y has a positive value, and in a fall state it has a negative value.
private void Update()
{
if (rigidbody.velocity.y > 0f)
{
animator.SetBool("Jump", true); // Игрок в прыжке
}
else
{
animator.SetBool("Jump", false); // Игрок в падени
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question