Patrolling issue
AssortDis
Member, PRO Posts: 22
Hi,
I need an actor to move back left or right when it reach the end of screen with the following rules but for some reason, it just stop when reach the end of screen without going back.
Move in direction 0 at speed 300
Rule
If self.position.x >= game.displaysize.width, move in direction 180 at speed of 300
Rule
If self.position.x <= game.displaysize.width, move in direction 0 at speed of 300
Thanks in advance.
Best Answers
-
Socks London, UK.Posts: 12,822
@AssortDis said:
Try this:
constrain self.position.X to:
(( game.Display Size.Width /2)- self.Size.Width /2) *sin( game.Time *100)+ ( game.Display Size.Width /2)
-
Socks London, UK.Posts: 12,822
@AssortDis said:
I'll need some time to figure out how exactly that formula works though ^^(( game.Display Size.Width /2)- self.Size.Width /2) *sin( game.Time *100)+ ( game.Display Size.Width /2)
⬤ Range of movement / distance (as a radius from the centre point)
⬤ Speed
⬤ Centre point of movement
Answers
@Socks
Thanks a lot, this gives a pretty great result without adding too many rules.
I'll need some time to figure out how exactly that formula works though ^^