Game Development Community

How To Target And Shoot At Cloned Objects?

by Jack-S- · in iTorque 2D · 02/24/2012 (12:41 pm) · 1 replies

Hi, I have problem here which involves the turret behavior, ( I could have also used the timer shoots) however problem is, I have a spawner sceneObject which spawns enemies which are cloned from an enemy somewhere off screen. trouble is my turret will only shoot at the original object which the clones are cloned from with the spawn area behavior and not the cloned enemies.
Does anyone know how to get around this??
Thanks in advance.

#1
02/29/2012 (5:28 pm)
How are you determining the turret's target? Is it by object name? For instance, your original object is named Enemy, and you're having your turret shoot at Enemy in code? You need to have the turret target the reference to the clone. For instance, you would do something like this:

%newEnemy = Enemy.clone();

Turret.target( %newEnemy );

In the above example, Enemy.clone() returns a reference to the cloned Enemy object and Turret.target( %newEnemy ) assigns the clone reference as the target (you have to make the target function, of course).