- Home /
Collision Detection not working properly
I followed this tutorial ([url]http://unity3d.com/learn/tutorials/modules/beginner/physics/on-collision-enter[/url])
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!
No , thanks for infor$$anonymous$$g me - the tutorial said nothing and its begginer-based . I have no experience
I am not very familiar with character controllers. I think you don't need to add physics and collider to it. Someone else maybe able to point you at the correct direction.
CharacterController comes with its own collider.(center, radius, height all collider properties). You dont need the second capsule collider. That might be the issue.
@aero80 U removed the second collider from the box and the second collider from the character. Nothing worked.... Im getting really pissed off
I added this line : print("collision !!!"); and it doesnt print in the console (outside of if statement)
Answer by Zarkopafilis · Apr 26, 2014 at 05:20 PM
Removed rigidbody from FPS controller - Added a capsule collider and made it a little bit bigger - Set collision detection on box's rigidbody to continuous
Answer by BlackHoleStorm · Apr 25, 2014 at 02:38 PM
There's 2 colliders on your qBlock object, try removing one of those and see if that helps.