How do I disable behavors for certain instances.

Get help using Construct 2

Post » Tue Oct 21, 2014 2:40 am

Hello.

I have two behaviors for an rts like game. path finding and turret. The idea is that if an object is moving it will disable the turret behavior so they will only move. but as soon as they are done moving the turret behavior is enabled so they can fire.

however upon testing I found that it turns the behavior on or off for all instances of that team. meaning that if at least one unit is moving none of the units on that team can fire. to try to fix this I added a variable "ismoving" that is 1 when is on the path and zero when stationary and added the turret behavior to the object instead of its family. however this did nothing.

How can I make it disable or enable the turret behavior for just an instance based on if it is moving or not?

Thank you.
B
10
S
4
Posts: 52
Reputation: 856

Post » Tue Oct 21, 2014 3:07 am

Construct2 uses a "pick" method to determine what instance to operate on at any given time. If you do not "pick" an instance it will apply the action to all. This is what you are experiencing.

You "pick" an instance by referencing it in the conditions portion of an event.

Sounds like you simply need to add a "is-not-moving" condition to the event that sets up your turret actions. You can do this via an instance variable in the object itself.

Add a .capx of what you got so far if that doesn't help you any.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333

Post » Tue Oct 21, 2014 3:28 am

here is a pic of the events that control it.
You do not have the required permissions to view the files attached to this post.
B
10
S
4
Posts: 52
Reputation: 856

Post » Tue Oct 21, 2014 4:06 am

@chrisinfinger is right. The instances picked by the 'Is Pathfinding' condition are forgotten in the next event (isMoving=1 condition) and so all instances are picked by default. One way is to directly Set Turret2 enabled/disabled at the time you do the Is Pathfinding. Another way is to create a Function to enable/disable the turret behaviour then loop through all instances at the point of picking, and pass each UID to the function in turn.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Oct 21, 2014 4:26 am

ohh that did it. Thanks guys!
B
10
S
4
Posts: 52
Reputation: 856


Return to How do I....?

Who is online

Users browsing this forum: bluesun66 and 2 guests