Change the actor graphic based on movement Left or Right
Having issues with building what i figured would be a dead simple solution. I want an actor to automatically move left and right and have the graphic on the actor change to match the direction moved.
I found Tshirtbooth's video on direction, but this won't work for me for some reason. I assume it's because I'm interpolating the motion to a random position rather than accelerating.
My code looks like this:
Every 5 seconds
Interpolate (selfpositionX) to (random 50,975) Duration (random 3/5) Ease In Out
Rule
When self.motion.linearvelocity.X < 0
Change actor Image (e.g. left)
Rule
When self.motion.linearvelocity.X > 0
Change actor Image (e.g. right)
Any ideas?
I found Tshirtbooth's video on direction, but this won't work for me for some reason. I assume it's because I'm interpolating the motion to a random position rather than accelerating.

My code looks like this:
Every 5 seconds
Interpolate (selfpositionX) to (random 50,975) Duration (random 3/5) Ease In Out
Rule
When self.motion.linearvelocity.X < 0
Change actor Image (e.g. left)
Rule
When self.motion.linearvelocity.X > 0
Change actor Image (e.g. right)
Any ideas?
Comments
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Create a variable (integer) called eg: currentlocation inside your actor.
Timer
Every 5 seconds
Interpolate (selfpositionX) to (random 50,975) Duration (random 3/5) Ease In Out
Change attribute (self.currentlocation) to (self.position.X)
Rule
When self.position.X < self.currentlocation
Change actor Image (e.g. left)
Rule
When self.position.X > self.currentlocation
Change actor Image (e.g. right)
Works great, sometimes it helps just to talk through the logic to find a solution!
Rule: when
self.Position.X < self.currentlocation
changeAttribute: self.Graphic.Flip Horizontally To: true/false (depends on the initial image's being a L or R view)
same for > self.currentlocation
less resource-draining than changeImage.
but, of course, wont work if the two images are totally different!
great thinking you did on that one @Toby … pat yourself on the back!
MH