What repercussions for this work around?

Game Editor comments and discussion.

What repercussions for this work around?

Postby Grynde » Sun Jun 30, 2013 5:15 pm

I have been struggling with clones.

After reading this threadhttp://game-editor.com/forum/viewtopic.php?f=27&t=12650.

And using the following:
Code: Select all
if ( distance(Player.x, Player.y, Enemy.x, Enemy.y)<=someDistance) {
    //do Stuff
                                                                  }

I ran into the obvious problem that the x,y position goes of clone.0. However I have a slew of cloned mobs and couldn't find a workable workaround for my skill.

However, I noticed that if I used this instead, I have the enemy doing what I want.
Code: Select all
if ( distance(Player.x, Player.y, Enemy.x, Enemy.y)>=someDistance) {
    //do Stuff
                                                                  }

With it continuously checking against the greater than value of the original enemy the other clones shoot like I want, but I am aware that what I'm doing is not correct.
What are the long term ramifications for doing such?
Playing a game is the voluntary attempt to overcome unnecessary obstacles.
-Bernard Suits
User avatar
Grynde
 
Posts: 21
Joined: Fri Apr 26, 2013 12:41 pm
Location: Virginia
Score: 1 Give a positive score

Re: What repercussions for this work around?

Postby AliceXIII » Sun Jun 30, 2013 10:59 pm

Are you calling this code on the enemy?

If so just assign the enemies x and y:
Code: Select all
distance(Player.x, Player.y, Enemy.x, Enemy.y); \\ instead of Enemy.x/y just do x and y


Because if your enemy is initiating the search for whether the player is close to them which it should then you would already have each clone independently searching whether it's within a certain distance of the player just instead of specifying Enemy.x which won't return the desired result with clones use a plain x or y.

Hierarchy of clones:

Enemy.1 -> Draw Event -> Script Event -> "check distance"
Enemy.2 -> Draw Event -> Script Event -> "check distance"

Enemy.1 and Enemy.2 know what actors they are when calling what is the same code but on a different clone so using a normal x and y would work because the clones effectively know which clone is calling what code at said time.

I believe this is what your looking for although I'm not a 100% sure.
"Taking a breath of fresh air."
User avatar
AliceXIII
 
Posts: 325
Joined: Fri Sep 17, 2010 2:36 am
Location: victoria, texas
Score: 37 Give a positive score

Re: What repercussions for this work around?

Postby Grynde » Mon Jul 01, 2013 1:29 am

AliceXIII wrote:Are you calling this code on the enemy?

If so just assign the enemies x and y:
Code: Select all
distance(Player.x, Player.y, Enemy.x, Enemy.y); \\ instead of Enemy.x/y just do x and y


Because if your enemy is initiating the search for whether the player is close to them which it should then you would already have each clone independently searching whether it's within a certain distance of the player just instead of specifying Enemy.x which won't return the desired result with clones use a plain x or y.

Hierarchy of clones:

Enemy.1 -> Draw Event -> Script Event -> "check distance"
Enemy.2 -> Draw Event -> Script Event -> "check distance"

Enemy.1 and Enemy.2 know what actors they are when calling what is the same code but on a different clone so using a normal x and y would work because the clones effectively know which clone is calling what code at said time.

I believe this is what your looking for although I'm not a 100% sure.

I am calling this on the enemy. Thanks Alice XIII, that makes sense. I new I was doing it a goofy way.
Playing a game is the voluntary attempt to overcome unnecessary obstacles.
-Bernard Suits
User avatar
Grynde
 
Posts: 21
Joined: Fri Apr 26, 2013 12:41 pm
Location: Virginia
Score: 1 Give a positive score

Re: What repercussions for this work around?

Postby AliceXIII » Mon Jul 01, 2013 1:45 am

Works well now?
"Taking a breath of fresh air."
User avatar
AliceXIII
 
Posts: 325
Joined: Fri Sep 17, 2010 2:36 am
Location: victoria, texas
Score: 37 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest