- Home /
Capsule collider going through terrain collider
I have made my own character controller with the following code
`GetComponent<Rigidbody>().MovePosition(transform.position + (transform.right * MoveSpeed * Time.deltaTime * Input.GetAxis("Horizontal")) + transform.forward * MoveSpeed * Time.deltaTime * Input.GetAxis("Vertical"));`
When I am moving my character, if he comes in contact with a vertical wall made out of terrain, he will pass right through this, I cant seem to find anything on here about this specific type of movement so I was wondering if anyone had any ideas as to why this may be happening
Answer by HenBOMB · Nov 28, 2018 at 09:44 PM
Make sure you Terrain 'Thickness' is set to 1
Unfortunately it is already at 1, i have tried changing it but it did not fix it.
Try using Rigidbody.velocity:
Rigidbody rb = GetComponent<Rigidbody>();
float speed = 2;
rb.velocity = new Vector3 (Input.GetAxis ("Horizontal") * speed, rb.velocity.y, Input.GetAxis ("Vertical") * speed);
Your answer
Follow this Question
Related Questions
Terrain rotating on collision,Terrain rotates on collision 0 Answers
Capsule Collider moving through vertical terrain 0 Answers
Sphere Collider with Terrain 0 Answers
unity 4.0 terrain collider issue 1 Answer
Player falling through Terrain collider 0 Answers