- Home /
first person controller help
I am using a first person controller to move my character in a game but my first person controller and character keep falling through the terrain I have colliders set up and nothing is marked as a trigger so what is happening that needs fixed?
Have you checked that the controller is not slightly clipping through the terrain? I normally have $$anonymous$$e a couple of units above the ground so it drops down. If the mesh is intersecting the terrain then it wont work.
Answer by PlasmaByte · Dec 29, 2013 at 02:38 PM
Use a rigidbody and a capsule collider, freeze the objects rotations though. Then you can use the velocity change forcemode to achieve the velocity you want. Sorts out all collisions nicely and even allows characters to push one another around if you want that.
public Vector3 targetVelocity = Vector3.zero;
void Update(){
Vector3 vel = targetVelocity;
vel -= rigidbody.velocity;
vel.y = 0; //prevents person flying
rigidbody.AddForce(vel, ForceMode.VelocityChange);
}
thankyou for your answer i dont really know why it did not work the first time but it does now so thanks again.
Your answer
Follow this Question
Related Questions
Collision Colliders - Box or Mesh for Terrain 1 Answer
Randomly some prefab instances have Character controller misaligned 0 Answers
How to limit walkable map? 3 Answers
Terrain collision problem 1 Answer