x


Spawning explosions and detecting objects in range

Hello!

Here's the deal. I got bombs (note to FBI: virtual ones). When they hit something, the bombs should spawn an immobile explosion that should deal X points of damage to all objects in range.

Now, I currently have a prefab for that explosion object. On that object is a trigger collider, a script, and a few other irrelevant components. In the script I react to OnTriggerEnter(), but that apparently is very unreliable.

I read elsewhere that colliders are quite finnicky, especially when spawned within each other. Might that be my problem? Or maybe there has to be movement in order for collisions to register?

How would you go about applying instant damage to all objects within a collider that was just spawned?

Thanks!

more ▼

asked May 12 '11 at 03:47 PM

microp gravatar image

microp
111 14 14 22

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

I believe that what you could do is use a spherecast with a radius of your explosion(http://unity3d.com/support/documentation/ScriptReference/Physics.SphereCastAll.html) . Then apply explosion force depending on how far away from the explosion the objects are. Hope this helps!

more ▼

answered May 12 '11 at 03:58 PM

logty gravatar image

logty
180 30 32 40

Hmmm, a sphere cast you say? I like it! Dunno how it's gonna cope with a distance of zero, but I'll try that out. Thanks!

May 12 '11 at 04:24 PM microp

I liked the visual, intuitive setup of the collider though. Also, is there a way to get the layer mask from the project physics settings?

May 12 '11 at 04:31 PM microp

I also liked the Enter and Exit notifications. Bleh, I really wish colliders weren't so broken.

May 12 '11 at 05:07 PM microp

Who says colliders are broken? Where did you "hear" this?

May 12 '11 at 07:31 PM flaviusxvii
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2482
x1682
x980
x438
x159

asked: May 12 '11 at 03:47 PM

Seen: 1639 times

Last Updated: May 12 '11 at 03:47 PM