Z
Z
Zimaell2020-07-02 13:53:08
Unity
Zimaell, 2020-07-02 13:53:08

How to check contact?

There are two objects (a flying projectile and an enemy), both have a collider, movement occurs and the projectile flies through the enemy, the question is how to determine that the projectile has collided?
I looked at the examples and it says the following

void OnCollisionEnter(Collision v){
  Debug.Log("tag=>" + v.gameObject.name);
  if(v.gameObject.name=="....") .....
  }

I put this in the prefab of the projectile ...
That is, theoretically, when the projectile collides with the enemy, a log with his name should appear, but nothing ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GFX Data, 2020-07-02
@Zimaell

At least one of the objects must have a RigidBody.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question