- Home /
Collision problem
Hi everyone. I got a simple problem. When my player collides into a wall or a block he goes right through it. He is free moving towards the right at all times. How can I fix this collision effect. And yes I have ridigybody tag along.
sing System.Collections;
public class MovementSpeed : MonoBehaviour {
private Vector3 moveDirection = Vector3.zero;
//private CharacterMotor chMotor;
private Transform tr;
private float dist; // distance to ground
void Start()
{
transform.position = new Vector3(-5,-0.7f,0);
}
void Update()
{
transform.Translate (0.10F, 0, 0 * Time.deltaTime);
}
}
Ok let me better explain this. The ball has the component of rigidbody and so does everything else. Now the blocks which the ball have to pass are kinematic, because the blocks need to phase through the ground. By the way this is an android game in which you will be able to slide the blocks down so the ball can go through, and if stop the game is over. Hopefully I explained it better. And no triggers are on.
Answer by Jeff-Kesselman · May 30, 2014 at 10:03 PM
Okay frist off, RigidBody is not a tag, its a component. Making your tag "rigidbody' would do absolutely nothing. All moving objects that you wish to collide with other objects need a RigidBody component.
Second, all objects that are party to a collision need to have a Collider component as well, moving or not.
Third, make sure your colliders are NOT set to isTrigger and that your RigidBody components are not set to "isKinematic".
Answer by matheusrma · May 30, 2014 at 10:04 PM
Hello GhostDre,
When you move a GameObject using transform.Translate() Unity does not apply physics to it, so it won't collide with anything.
Try using a Rigidbody or a CharacterController and you should be ok
Your answer
Follow this Question
Related Questions
making bullets disappear when they collide 3 Answers
RigidBody Clings to Walls 0 Answers
No gravity when running against a wall (2D) 1 Answer
How to block a raycast? (Java) 1 Answer