Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 28, 2017 15:57:28 GMT
Hi,
i made some missiles that use unity's particle systems for smoke trail. Particle system is in a child object attached to a missile so upon collision it can detach and particles can finish their limetime (otherwise the object holding the particles system and the particles disappear in the instant the missile is destroyed).
Naturally (you probably know by know, i use PlayMaker), i use OnCollision2D and detach children, but it doesn't work properly, the destruction of the killable object happens before the detachment of the child object as i can see in the log (null reference). I also tried listening to missile HP and detach children when it gets under 1 but it also doesn't work (except i don't get the null reference error since the detach state doesn't even happen, so it probably starts in the later update). I also tried getting the distance but that also doesn't work since the missile hits the collider, not the object itself.
Any ideas on how to solve this properly? The reason i'm asking this here (i also posted the question on Hutong Games forum) is to see if i can use some of the possibilities of the killable to this avail?
|
|
|
Post by DarkTonic Dev on Jan 28, 2017 18:21:39 GMT
I think you will need to do code for this one, because you're going to need to detach before the Killable calls Despawn on itself. If you are willing, I can let you know where the code would need to go.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 29, 2017 7:18:36 GMT
Hi, actually i managed to pull it off meanwhile. I tried getting the parent, and when object is null, the particle system should disable itself. But it's never null, it just goes back to the pool.
So i did it like this:
Set the missile to have X number of hit points and HP Death Mode to Zero Hit Points On Collision2D Store Collider (enemy that's been hit) Send an event to detach the child object Apply damage to collided game object and then X damage to itself
It all happens in two frames, so it looks simultaneously done.
|
|
|
Post by DarkTonic Dev on Jan 29, 2017 7:29:43 GMT
Ok cool then!
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Jan 29, 2017 20:26:49 GMT
|
|
|
Post by DarkTonic Dev on Jan 29, 2017 20:31:11 GMT
Excellent.
|
|