Movement within Radius
mojomajojo
Member Posts: 12
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
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
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
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
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