- Home /
my player y axis value is constant and does not change .,my character is not changing position along y axis?
i started doing the project since i'm a beginner i took some help from online tutorials and all but my character is struck on y-axis, it can go on higher value of y but it does go back to 0 OR ground and stays in the air only . Also For better understanding i'm giving the video link properly showning the issue, as you seee the video u can see the y-axis value is constant and it does go up when i climb the slope but does not resets to ground. I hope to get some help.link text
Do you have a Rigidbody component attached to the player
Answer by BRUTALB3AST · Jul 27, 2021 at 11:44 AM
Yes, I have a rigid body attached to my player.
i know this might sound stupid but a lot of people make this mistake. are you sure your mass, gravity and gravity scale are all 1 or higher
Answer by tyruji · Jul 27, 2021 at 07:17 PM
It's because you are not applying gravity to your character. You are using a character controller, which is just a collider with an additional Move() method. Here some example code on how you'd implement gravity:
[SerializeField]
private CharacterController _Cc = null;
[SerializeField]
private float _Gravity = 9.81f;
private Vector3 _vel = Vector3.zero;
void ApplyGravity()
{
_vel.y -= _Gravity;
if( !_Cc.isGrounded ) return;
_vel.y = -_Gravity;
}
Good luck!
Your answer
Follow this Question
Related Questions
Create 3d hexagonal terrain 1 Answer
Make a player only move in one direction 1 Answer
Difficulty with gaze function 0 Answers
How to change a GameObject's direction after collision?, 1 Answer