magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 28, 2017 19:43:30 GMT
The "Disable Colliders Also" functionality of this feature doesn't seem to work. I have a spaceship with turret placement points. Upon spawning the spaceship, it finds the turret placement points and spawns child killables. This mostly works. I can shoot the main killable and it never gets damaged, but the collider for the killable is getting hit still and preventing the player lasers from hitting the turrets. So, I check the "Disable Colliders Also" checkbox, but the colliders are still enabled. I ended up disabling them in code and re-enabling them later when the turrets are destroyed, but it would be nice to have this feature working. Perhaps it's because I'm spawning the child killables after the main killable is already spawned?
|
|
|
Post by DarkTonic Dev on Sept 28, 2017 19:50:20 GMT
Yes, that is why. Killable only checks for children during the Spawned event. If the children aren't there it has no way to later know that children suddenly exist. MonoBehaviour has no event for us to hook into like "NewChildAdded", although that would be great.
If you are spawning the children after the main is already spawned, you will need to call the parent Killable's method "RegisterChildKillable" with each child so it will know a new child exists. That will disable the colliders. You are spawning and then re-parenting them under the main Killable, right?
|
|
|
Post by DarkTonic Dev on Sept 28, 2017 19:55:23 GMT
It turns out they did add something to MonoBehaviour sometime, OnTransformChildrenChanged. But I've found that these sort of methods are pretty dangerous to use because they will most likely fire at other weird unexpected times and cause errors, so I'm not going to integrate with it.
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 28, 2017 19:55:45 GMT
That's kind of what I suspected, but wasn't sure how to get around it. I'm using PoolBoss.Spawn and specifying the parent as the parentTransform parameter. Thanks for the quick reply. I'll try the technique you suggest.
|
|
|
Post by DarkTonic Dev on Sept 28, 2017 20:22:02 GMT
Actually, I did a quick test and it works fine for me, as long as you are calling the PoolBoss.Spawn method and passing the Transform of the parent Killable. The child must have a Killable component or it doesn't work.
If you aren't seeing the same, you will need to send me an example project that shows the problem. I was testing on old Unity though. Unity 4.5
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 28, 2017 20:26:59 GMT
Actually, I did a quick test and it works fine for me, as long as you are calling the PoolBoss.Spawn method and passing the Transform of the parent Killable. The child must have a Killable component or it doesn't work. If you aren't seeing the same, you will need to send me an example project that shows the problem. I was testing on old Unity though. Unity 4.5 OK, I will have to experiment a little and see if I'm doing it the same way and see if the issue is still there. I'll let you know.
|
|
|
Post by DarkTonic Dev on Sept 28, 2017 20:49:17 GMT
ok
|
|