Im in camera script and I need the y velocity of player.
(Im ultranoob, 3 days using unity and Virtual Studio)
I search all my doubts in internet, make the jump function made me like 5 hours, but i dont need to answer nothing. I say this because if im am asking it is because i can find nothing similar that works for me. I dont want to disturb you.
Look:
void LateUpdate()
{
transform.position = target.position + offset;
if (Input.GetKey("s"))
{
transform.position = new Vector3(target.position.x, target.position.y, target.position.z - 10);
}
}
(“target”) is player position vector3, it is up in code, but is nor relevant here.
So, by pressing S camera downs and allow you to see below (you are crouching)
Problem is that i dont want to crouch when player is falling (or jumping), so, i want if y velocity of the rigidbody of the gameobject player == 0, you can jup.
Someting like that
void LateUpdate()
{
transform.position = target.position + offset;
if (Input.GetKey("s") && **y velocity of the rigbody of the player is 0**)
{
transform.position = new Vector3(target.position.x, target.position.y, target.position.z - 10);
}
}
Sorry if this is too easy, but i spent hors trying it, i can call “public GameObject player;” but not his y velocity.