Character doesen't collide

Heyhey… I am currently trying to make a platformer in unity. I started writing code for the Character but it won’t collide with anything, though the character and the surroundings have collider components attached. The following code is for the Character…

private var CharMovement = Vector3.zero; 

public var speed = 2;

function Update () {

Movement();

//Actually move Character
transform.Translate(CharMovement * Time.deltaTime);

}

function Movement ()

{

if(Input.GetButton("Right"))
{	
	CharMovement.x = -1 * speed;
}

else if(Input.GetButton("Left"))
{	
	CharMovement.x = 1 * speed;
}

else
	CharMovement.x = 0;

}

Sry I am new to unity… please help

Does your character have a rigidbody attached to it? If it doesn’t, I would suggest you add this and set it to isKinematic since you are moving the character by means of Translation and not adding physics forces to it.

A game object with a collider but without a rigidbody is considered a static collider, and typically should not be moved in a scene:

These are GameObjects that do not have
a Rigidbody attached, but do have a
Collider attached. These objects
should remain still, or move very
little. These work great for your
environment geometry. They will not
move if a Rigidbody collides with
them.

The collision system is best used in conjunction with rigid bodies and physics. If you want you can try and switch to Triggers instead which may be a little bit more reliable if you do not plan on using rigid bodies.

if you are using java script, it is:

CharMovement.x -= 1 * speed;//right
CharMovement.x += 1 * speed;//left

since you didn’t put"+=/-=" and put a “=”, the command might have interfered with the regular physics

Thank you for the fast answers. I tried both approaches and still the Charakter-Dummy slides through the ground plane. When I turn “is kinematic” off in the rigidbody, the Dummy behaves correctly and collides with the floor… very weird… Here is a Picture of my Problem