How do I disable behavors for certain instances.

0 favourites
  • 5 posts
  • 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.

  • 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.

  • here is a pic of the events that control it.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • ohh that did it. Thanks guys!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)