Enemy Patrolling and Image Flip
I am trying to write a simple behavior for an enemy type. I want them to move back and forth with the speed and distance of movement determined by an attribute. I got that part working. However, I also want them to flip their image to face the other way once they switch directions.
So far I have used a Constrain location with Cos function to make it pass back and forth over a center point (no way to indicate to actor direction its moving in, that i can figure of), a pair of spawned waypoints to redirect movement and trigger a flip (multiple enemies crash into each others) and a change velocity at Distance+Patrol Range (it doesnt register the flip more than once). So none of these work for that feature. Does anyone have a suggesiton? (There is currently no animation, this is partly a test.)
Comments
Cos works on an angle (the value within the brackets).
Cosine centre point = 0
Far left = -1
Far right= +1
All you'd need to do is . . . . hold on, quicker to do a demo, back soon . . .
Yeah, that's where my skill breaks down. I'm good at understanding the components of code, and can figure out what pieces do what, but I'm actually very bad at trig math in general, so I'm not good at modifying it in new ways without an existing example. So, is there a way to track the path of the cosine between those three points and watch for when the delta is going up or down?
@Tosanu, this is the tutorial, i used for the Enemy Patrol code in my game that I am working on, Sour Blob.
http://www.jamie-cross.net/?portfolio=gamesalad-recipe-007-enemy-behavior-patrolling
hmm, the difference was I was marking the Horizontal flip with True/False and not 0/1. Is that likely to make it read differently?
true is the same thing as 1 and false is the same thing a 0. BUT true and false should be lower case, it's case sensitive.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Thank you. Unfortunately, that didn't help for some reason. Note, since i'm trying to spawn enemies with an automatic system and adjusting their status manually isn't preferred, i'm setting the range as MyPosition + and - Patrolrange, and checking for less than/greater than or equal to that total. For some reason it only flips once and then never again. Is the way im setting it up a bad idea?