#ground detection not working UNITY3D
1 messages Β· Page 1 of 1 (latest)
the gravity is a acceleration force
if i were to always apply gravity, the player would fall faster and faster regardles of thes fact that he is standing on the ground
get the remaining velocity after moving and set the velocity to that. if you're on the ground, it will be 0.
its 4 am what
.
actually no, it doesn't seem to do that
i guess just use a rigidbody and add forces manually
i just learned the basics of the character controller π
and i found a thing that was bothering me
i never seen anyone actually use it for that
π
also, i don't use unity, so maybe i'm just being dumb
thanks for the help you were VEEEEEEERY helpful
sorry
looked it up again and it looks like the leftover velocity is set automatically
so you should always be applying gravity
not all of the code is shown but from what i see it looks like currentGravity is remembered across updates
don't do that, just add to velocity
// The class
private Vector3 velocity = Vector3.zero;
// ...
Vector2 moveDir = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
velocity.x = moveDir.x;
velocity.z = moveDir.z;
velocity.y += -9.81f * Time.deltaTime;
characterController.move(velocity * Time.deltaTime);
actually no, you do have to set the y velocity to 0 when grounded
yeah...
you need a rigidbody if you want to slide off
i don't, thats the point
are there any better solutions to fix the isGrounded properity WITHOUT using rigidbody?
that is grounded, itβs just that charactercontroller wonβt do sliding, only your movement from code
i don't use the isGrounded anywhere else
charactercontroller only moves in one direction and stops when there is a collision. it doesn't slide.
