How do I make a objects instance variable depend on anothers

Get help using Construct 2

Post » Wed Aug 26, 2015 9:20 pm

I'm trying to make AI for an enemy and i want to make them run to where they last saw the enemy. To do this, i made a sprite that would spawn when the enemy sees the player. The problem is, how does the game know which enemy has seen the player. To fix this I made an instance variable for the enemy and the sprite that last saw you. I then made the enemy have a random number and tried to make the object that follows the player that same value but i cant get the object that follows the player's instance variable to be dependent on the enemy's instance variable. Please Help :).
Posts: 1
Reputation: 152

Post » Wed Aug 26, 2015 9:54 pm

I call this the "Mate" variable (literally I do, but it isn't its technical term).

I'll try explain it:

When you create the sprite which is associated with the player or the enemy, assign a variable in itself to the UID of the object it is associated (or tracking in your case) with. Then when you want to conditional or action against it, pick the Object by UID against the "Mate" variable.

If this doesn't make sense let me know and I'll try get a capx or screenshots sorted.

Keep in mind using IID for references in enemies and sprites can cause issues because if an enemy or sprite is destroyed, the IID for the next enemy/sprite can conflict
Stuff I'm working on:
Posts: 88
Reputation: 1,035

Post » Wed Aug 26, 2015 10:12 pm

Message: BackendFreak can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
You may also want to pick the instance by the "instanceName" which can be a generated text. I have explained that here
Posts: 1,106
Reputation: 50,658

Return to How do I....?

Who is online

Users browsing this forum: OddConfection, Strawoy, zenox98 and 67 guests