I followed this tutorial (http://unity3d.com/learn/tutorials/modules/beginner/physics/on-collision-enter)
And here is how my project looks like.(Its the FPC - player and 2 cubes. 1 for the ground and one named “qBlock”)
I want to destroy the qBlock as soon as the player collides with it(i.e. jumping ontop , on bottom etc)
Code attached to the player:
#pragma strict
function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.name == "qBlock"){
Destroy(collision.gameObject);
}
}
And this will help too:
(I have not messed around with any physics settings…)
Update; I added rigidbody and collider to the box (disabling gravity - i want it to float). When I try to add these to the player , weird things happed (he ususally goes up into the sky)
When the capsule collider is added to the player and i press ‘W’ to move forward , he is getting launched into the sky.How can I fix that?
I also tried having the collider on the graphics child of player. Nothing worked!