How do I Make Multiple Companions

Get help using Construct 2

Post » Wed Oct 07, 2015 4:17 am

So I have been using the example here viewtopic.php?t=65215&start=0#294672 to try and figure out how to make multiple companions that have the same behavior. The problem I am running into is when I clone, or create more of the fairy object, they all float to the same spot. Its like they are not setting themselves as their own x and y positions.

So the fairys are scattered throughout the layout, and I only want them to start following when they come within a certain distance of the player. I figured that part out by changing the greater than sign to less than. I still have the problem though, that all the fairies congregate at the same spot on the layout when it loads, even if I change the call to set xPos to fairy.X (fairy2, fairy3, and so on) instead of self.X in all instances it asks for self.

What do I have to do or am I doing wrong to get each of them to stay put where they are placed on the layout until the player comes close to them?
Posts: 71
Reputation: 975

Post » Wed Oct 07, 2015 8:20 am

In the example you are using the variables are global..
All the fairies will have the same target, for they all use the same target-variables..

Giving the fairies instance variables and setting them for each would be a good start in solving a your issue..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
Posts: 6,160
Reputation: 19,775

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests