I’m a little confused of how to use CharacterController component.
Accroding to to docs :
“A CharacterController is not affected by forces and will only move when you call the Move funtion. It will then carry out the movement but be constrained by collisions.”
When I use it on character I really can through trees and boxes but When I move my player off the ground and start the game it goes through the ground…it seems that no collision is detected (as far as I see it) so why my player bumps into vertical object and not horizontal like the ground?
please help me
Thank u in advance
My guess is that this is your problem:
I’m using script to modify the
Note: I might be misunderstanding this phrase since technically the CharacterController will modify the transform as well, but if you mean that you are directly modifying the Transform, then read on.
Directly modifying the tranform’s position will not use Physx to check collisions. Instead you should replace your direct transform manipulation (transform.Translate() or transform.position += someValue) with a call to CharacterController.Move()
var moveDirection : Vector = transform.TransformDirection(Vector3.forward);
moveDirection *= moveSpeed * Input.GetAxis("Vertical");
var gravity : Vector3 = new Vector3(0 , -10 , 0);
//You probably have all the above code in your script already. This just gets a forward direction
//and adds gravity.
var controller : CharacterController = GetComponent.<CharacterController>();
controller.Move( moveDirection * Time.deltaTime );
//This is the part you want to add if you don't have it. This gets the CharacterController
//Then moves the object via the CharacterController function Move().
This is my guess, but I’m not sure why you can collide with trees and not the ground as you stated.