- Home /
Question by
Klousianic · Aug 07, 2014 at 02:39 PM ·
movementcolliderplayercharactercontroller
CharacterController doesn't work with collider
Hi I make a 2d game. The Player moves up and I can move him to the left and the right side. Now I want that he can't move out of the view so I want to create cubes at the left and right sides. But everytime he moves through the cubes. Here is my movement script:
var moveDirection : Vector3 = Vector3.zero;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
controller.Move(moveDirection*Time.deltaTime);
if(Input.GetKey("d"))
{
//transform.position = Vector3(transform.position.x+5*Time.deltaTime,transform.position.y,transform.position.z);
}
if(Input.GetKey("a"))
{
//transform.position = Vector3(transform.position.x-5*Time.deltaTime,transform.position.y,transform.position.z);
}
}
Comment
Answer by APenguin · Aug 07, 2014 at 03:40 PM
If i remember correctly, your object that uses the character controller has to be a rigidbody
Hi I didn't want that he fall I want that he goes up and not down but thanks