P
P
PurgaBot2021-09-27 18:29:43
Unity
PurgaBot, 2021-09-27 18:29:43

How do I code a falling object to be removed when it touches the floor in Unity?

How do I write code where my falling object should be removed when it touches the floor?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Kuzmenko, 2021-09-28
@morex972

Add the OnTriggerEnter method, throw the script on the object that will be deleted, select the floor, click on the button with tags and select add tag 6152f3462178a265504147.jpeg, a window will open and there you add the floor tag, or you can call it differently 6152f391d00d5308831670.jpegin the script in the OnTriggerEnter method, write

void OnTriggerEnter(Collider other)
{
if(other.gameobject.tag == “floor”)
{
Destroy(this)
}
}

N
Nekit Medvedev, 2021-09-30
@NIKROTOS

I saw a lesson in which rays were used for this. We draw the beam from the past position to the current one and if there is a floor in its path, we remove it. (In this case, the object will be removed even at high speed) There it was used for bullets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question