- Home /
Can't detect collision.
I have a problem with collision detection. I have my character, he is moving to the z axis automatically. I have some columns and i want to detect collision with the character...but nothing happens.
Character Movement Script(JS):
function speed_up(){
for(var i = 0; i < 200; i++){
yield WaitForSeconds (10);
if(speed < 9){
speed = speed + 0.3 ;
InvokeRepeating("speed_up", 0, 2);
can_speed = false;}else{return;}
}
}
Collision Script:
function OnCollisionEnter(collision: Collision) {
Debug.Log("LOST");
if (collision.gameObject.tag == "Block"){
DefeatText.active = true;
Time.timeScale = 0;
Debug.Log("LOST");
}
}
The Column :
The Character :
TRIED ALSO WITH RIGIDBODY Nothing Happened
Thank you so much for your time!
Review the doc for Collision and meet the criteria for one.
Try changing the mesh collider on column to be convex.
Didn't see a rigidbody. Not try, its a must. just saying :) ( Attached to the player )
Also Didn't see a collider attached to the "Block" mesh.
Also if you move player too fast. just try it with slower movement. and see.
Answer by voporak5 · Aug 13, 2015 at 06:52 PM
one of 2 objects needs to have a rigidbody.
both objects need to have colliders.
the moving object needs to move with physics (AddForce).