[solved] Question about collision and physic

Hello everyone,

I’ve got a problem with my collision. Oh I think it’s a very nooby problem, but it begins to burst out my head…

I created three boxes : a ground, a wall and a player.

I set a rigidbody on my player and i put a script to move him :

var speed = 5.0;

function Update () {
	var x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
	var z = Input.GetAxis("Vertical") * Time.deltaTime * speed;

	transform.Translate(x, 0, z);
}

Well… You ever saw this ! Haha !

Ok, my problem is that when my “player” is moving to the wall, he is “shaking” like when he wants to go through the wall and come back, and again, and again… I ever saw this in darkbasic when i tried to make my own collision system (how boring…). I wonder if there’s a trick to dodge this problem.
Should i add more script ? Where could i found usefull information about my problem ? (i’ve already saw the “Physic” section and it didnt help me)

Thanks !

if you want physics and collision, don’t use translate.
Translate is a non physical movement.

use forces and impulses instead

If it’s a player you’re trying to create, it may also be easier to use the CharacterController component, as its designed for moving around characters. If you use the Move function you will have to do your own movement physics calculations, but it takes collisions into consideration, so if you move the controller into a wall, it will collide with that wall and stop it from moving through. If you use the SimpleMove function for movement, gravity is calculated automatically for you.

Wow thank you for you reply, i’ll try this.

EDIT (20 minutes later yeah) : It works well ! Wouhou ! My problem is that i thought there was only ONE solution to move. Hoho ! I should have searched “move” in theUnity Script Reference… Ok thank you again !