X
X
xXx_Unity_xXx2021-12-29 10:24:38
Unity
xXx_Unity_xXx, 2021-12-29 10:24:38

How to do explosion damage in Unity 2D (so that everyone who was in the explosion radius receives this damage)?

I would be grateful even for the idea of ​​​​implementation. I have a rocket flying out of a rocket launcher explodes logically. (2d)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Ente, 2021-12-29
@xXx_Unity_xXx

You hang collider2D (set IsTrigger=true) and rigidbody2D (set IsKinematic = true) on all objects that should be subject to explosion. Then you create a prefab with an explosion, also set a collider with IsTrigger=true for it, and then in the script on the objects, on collisions, the OnTriggerEnter2D function will be called for you. In it, you can find out which trigger the object collided with and the intersection point.

F
freeExec, 2021-12-29
@freeExec

To find out who gets in the explosion radius
https://docs.unity3d.com/ScriptReference/Physics.S...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question