my character is moving through walls

My character is moving through walls with the new script I am using to move in world axis. I was wondering if someone could help me so that it dosent go through walls.

var fixedDirection:Transform; //drag 'n drop the "Direction" game object to this slot.
var speed:float = 1.0; //Change to whatever you want.

function Update(){
 transform.Translate(fixedDirection.forward * Input.GetAxis("Vertical") * Time.deltaTime * speed);
 transform.Translate(fixedDirection.right * Input.GetAxis("Horizontal") * Time.deltaTime * speed);
}

i dont understand why it is doing it.

any help would be appritiated.

When you simply adjust the transform like that, it doesn’t care about collision control. Here’s how I would do it:

var controller:CharacterController = GetComponent(CharacterController)
var MoveDirection:Vector3 = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical");
MoveDirection = transform.TransformDirection(MoveDirection);
MoveDirection *= speed;

controller.Move(MoveDirection * Time.deltaTime);

The Character Controller must be attached to your character (Component->Physics->CharacterController). For a better version of this script, look up the documentation for CharacterController.Move().

Not sure if you have already done that!? But try attaching a RigidBody and a Collider to the game object in question. And you might check the objects your “controllable” game object collides with. They need at least RigidBody attached… maybe also a Collider. Read that up in the unity3d api reference: http://unity3d.com/support/documentation/Components/class-Rigidbody.html

You will find the entry for the Collider yourself :slight_smile:

Peace and good luck

Check out CharacterController.SimpleMove should be what you need. :=)