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 :).
B
2
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:



http://www.jamdonut.com
B
13
S
3
Posts: 88
Reputation: 1,025

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 https://www.scirra.com/forum/how-to-quot-construct-quot-an-object-name-using-variables_t152556?start=10.
ImageImageImage
B
27
S
16
G
80
Posts: 1,021
Reputation: 44,761


Return to How do I....?

Who is online

Users browsing this forum: 25games, brunopalermo, dop2000, maranpis, missile, oosyrag, zill and 27 guests