Movement within Radius

Hello,

I have a map build of hexagons where each hexagon plays a different role, now I want my main character to move from hexagon to hexagon but only when I click on it and when the actor is in range to do so.

This has been a challenge to do so far I've tried magnitude on prototypes but couldn't make it to work. For starters I have only one prototype that is duplicated all over the map and every self atribute I change get's changed for all the others as well.


Do you guys have any ideas on what approach should I use ? Or what approach should I take in to solving this problem ?

Kind regards,
Mojo

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Make two game-level attributes; newX and newY

    In the hexagon prototype use the following rule:
    When mouse button is down
    --Change Attribute: newX To: self.Position.X
    --Change Attribute: newY To: self.Position.Y

    In the hero actor use something like the following rule:
    When mouse button is up
    --Change Attribute: self.Position.X To: newX
    --Change Attribute: self.Position.Y To: newY
  • mojomajojomojomajojo Member Posts: 12
    Thanks RThurman this works but only partially :( it doesn't solve my radius movement problem unfortunately. I want the main character to be able to move only to the hexagons in reach (the ones around him).

    I don't want to let the user to be able to move from bottom to top of the screen, just by pressing on top of it.

    Thank you again,
    Mojo
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited December 2012
    Make an attribute; theDistance

    In the hero actor use something like the following nested rules:
    When mouse button is up
    -- Change Attribute: theDistance To: magnitude(self.Position.X-game.newX, self.Position.Y-game.newY)
    -- When attribute theDistance < 100
    ---- Change Attribute: self.Position.X To: newX
    ---- Change Attribute: self.Position.Y To: newY
  • mojomajojomojomajojo Member Posts: 12
    Thank you RThurman, this worked just fine.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    You are welcome!
Sign In or Register to comment.