• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

"With" function problems with x&y coordinates

  • Thread starter Anthony Summers
  • Start date
A

Anthony Summers

Guest
xx = self.x;
yy= self.y;
player = playerTactical.selected);
with(player){
path = path_add();
path_add_point(path, playerTactical.selected.x, playerTactical.selected.y, 100);
show_message(string(playerTactical.selected.x) + ": " + string(xx));
path_add_point(path, xx, yy, 100);
path_start(path, 16, path_action_stop, 0);
}

This code is in the event of the left click for an object. When you click the object it makes a player walk to it. However I'm having an issue. As shown with my show_message statement both of my x values reveal to be the same. The player however is much farther both y and x.

I made xx equal the objects x position before we went into the with statement as I believed that would mess it up. However it still shows the object and the player having the same x position.

What is happening?
 
A

Anthony Summers

Guest
solved, i guessed. xx and yy needed to be var xx and var yy. Can someone explain this?
 
L

Ludorverr

Guest
D

Deanaro

Guest
You have to use other.xx and other.yy

You could also just use other.x and other.y instead of copying tha variable

The "other" keywork is used to access the instance that called the with statement
 
Top