- Home /
,Rigidbody falling through objects
My Player (which is a ball) goes through the enemy when I collide with him then starts falling through the plain? I got a Rigidbody and Sphere collider attached to him. The Rigidbody does not have a tick in the box. Any ideas please? It seems to be my Baddie script that seems to be the reason my player goes through the enemy. I took it off it collides but I also want it to respawn to the start of the level. The script does not have a tick init nither. Do you know any baddie scripts that will work for a ball colliding in to an enemy. thanks
Answer by RehanSanish · Feb 22 at 06:38 PM
Does the enemy have a box collider attached to it? If not, try putting one on it.
Yeah I already got a box collider attached to my enemy. My baddy script seems to be the issue becuse it does not have a tick in the box. Here's my baddy script thanks:
Using unityEngine;
public class Baddy : MonoBehaviour { private void OnCollisionEnter(Collision Collision) { if (Collision. gameobject..compareTag("Player")) { Destroy(collision.gameobject); } } }
Is your script attached to the player or the enemy? If it is to the player, then put it on the enemy instead. Otherwise, Your script looks fine to me. Also, is your project 2D or 3D? If it is 2D, use Box Collider 2D and if it is 3D, use Box Collider.