toggle menu
Categories
Discussions
Dashboard
Sign In
·
Register
Sign In
·
Register
Categories
Discussions
Dashboard
Sign In
·
Register
×
Home
›
GameSalad 101
›
Working with GS (Mac)
Comparison
Synlight_Development
Member
Posts:
10
March 2013
in
Working with GS (Mac)
How can I make it so that the enemy only moves if the player is within 100 of the enemy? Like if player.x - enemy.x <= 100?
Comments
tatiang
Member, Sous Chef, PRO, Senior Sous-Chef
Posts:
11,949
March 2013
edited March 2013
Just create a game attribute of type integer and set it to 100, and then reverse the equation:
When game.oneHundred >= player.x-enemy.x ... [behaviors]
Or, solve your equation for either of the attributes:
When player.x < = 100 + enemy.x ... [behaviors]
Or, constrain game.enemyDistance to player.x-enemy.x and then use that attribute in a rule.
Sign In
or
Register
to comment.
Comments
When game.oneHundred >= player.x-enemy.x ... [behaviors]
Or, solve your equation for either of the attributes:
When player.x < = 100 + enemy.x ... [behaviors]
Or, constrain game.enemyDistance to player.x-enemy.x and then use that attribute in a rule.