Select and Deselect Actors

Hello, I am currently making a real time strategy game like age of empires/the settlers/age of mythology.

Now I have a worker on my screen. When I tap on the worker it 'activates' and I can tap anywhere on the Screen to move him to. Now on my interface I have a button called 'Deselect'. If this button is hit I would like to deselect my worker so he cant move anymore.

I created an Attribute called 'Select'. It's a boolean

In my Actor Deselect I put the Rule

If Touch is activated, change attribute Select to Select +2

In my Worker I put Rule

If Attribute Select equals 2 then destroy this actor, and spawn actor Worker on the exact same position.

(This way the worker will respawn and will need to be selected again to move)

The value +2 is because when u tap on the worker the value goes to +1 and u will need value 1 to select the worker.

But it doesnt work, I can select the worker then move it to anywhere I want, but as soon as I hit the deselect button The actor just stays wherever it was and destroys itself after about 10 sec and never respawns.

Is there any other solution to deselect / select an actor?

Comments

Sign In or Register to comment.