#Collisions

1 messages · Page 1 of 1 (latest)

cunning moth
#

thread here

#

OnTriggerEnter is invoked if a collider on the same object is involved in a collision where at least one collider is a trigger.

#

It's also invoked if the object has a Rigidbody and one of its children is involved in such a collision.

#

But let's step back from that for a moment.

#

Can you explain what your game needs to do?

wanton gulch
#

Right

cunning moth
#

No technical terms.

#

Just describe the gameplay.

wanton gulch
cunning moth
#

Okay, so each obstacle could be destroyed separately?

#

you don't need to destroy them at exactly the same moment

#

they just need to be destroyed when they hit the wall

wanton gulch
#

Yeah

cunning moth
#

Then just put the destroy logic on the two boxes

#

and have them destroy themselves

wanton gulch
#

Like attach a script to the obstacle being spawned?

cunning moth
#

Correct.

wanton gulch
#

Okay Ill try that

cunning moth
#

I'd call it Obstacle

#

because that's what the thing is

#

an obstacle

wanton gulch
#

Yeah I already called it Obstacle

#

How would I make it destroy itself?

#

Just Destroy();?

cunning moth
#

Destroy(gameObject) will destroy the game object the component is attached to.

wanton gulch
cunning moth
#

Your spawner could do it every few seconds

#

Or it could wait for both objects to be destroyed by checking if they both equal null