Page 1 of 1

Adding auto turrets onto destroyable objects

Posted: Tue Sep 01, 2020 11:34 pm
by kiprobin
I added a destroyable frigate ship onto a ground map, and i put some auto turrets on it. Everything works fine, except when the frigate is destroyed, the auto turrets I put on it are still floating there. Does anyone know how to make it so that the auto turrets are destroyed when the frigate they're attached to is destroyed?

Re: Adding auto turrets onto destroyable objects

Posted: Wed Sep 02, 2020 8:30 am
by AnthonyBF2

Code: Select all

OnObjectKillName(
		function(object, killer)
			KillObject("imptur1")
			KillObject("imptur2")
			KillObject("imptur3")
			KillObject("imptur4")
		end,
		"impturretmain"
	)
Paste this code in your map script after ScriptPostLoad()
impturretmain = change to the name of your frigate object (instance name, not ODF name)
Add or remove more KillObject() lines to match the number of items you want to kill, with each line targeting another turret's instance name.

Re: Adding auto turrets onto destroyable objects

Posted: Wed Sep 02, 2020 1:46 pm
by kiprobin
Works like a charm! Thank you very much!