|
Ok, so I unfortunately hate to post a lot, because through trial and error I can usually get what I want working by reading other peoples help request, and also just working through 10 different ways and eventually finding it. The outcome I want (Which i thought the end line of code would do) is that if i collide with a child object (a sphere in this case) I want both the child and the parent, and the projectile to get destroyed, all 3 gone. Thank you. Everything is working fine: Hit the parent object, both child/parent and projectile gone, but when I hit the child, only the child/projectile die.
(comments are locked)
|
|
You are destroying the script, before it can destroy the parent, just get rid of the destroy child thing, because it will destroy the child anyways!! Btw don't ever have empty function just lying around, that's terrible coding. Benproductions1 Hope this helped I've already cleaned up his code ;)
Aug 08 '12 at 10:43 AM
Bunny83
(comments are locked)
|
|
All you need is: When you destroy the parent, all childs will also be destroyed. Btw. You should be the destroy check before you link the fixed joint... Yes I forgot about telling him to put the fix joint thing after the destroy, but why the return; ?
Aug 08 '12 at 10:51 AM
Benproductions1
;) Because it's useless to attach a fixedjoint when you destroyed both object right before ;)
Aug 08 '12 at 11:17 AM
Bunny83
Yes, but that part of the code would never run, since the script got destroyed, making the return; completely useless! That's whyI don't understand why you put it there???
Aug 08 '12 at 12:23 PM
Benproductions1
Thank you for the responses and the cleaned up code, unfortunately it's still not responding when colliding with the child asset.
Aug 08 '12 at 01:52 PM
justinsroy
The script will complete this function. Destroy is always delayed until the end of the current frame. Destroy can't make you exit the current function the only way is to exit it manually (with a return) or you raise an Exception which will also terminate the execution and depending on where the next try-catch block is it could even terminate your application.
Aug 08 '12 at 02:32 PM
Bunny83
(comments are locked)
|

Could you properly reformat the code, so that it is readable?
Can you update to your latest not working code?