Enemy Patrolling and Image Flip

TosanuTosanu Member, PRO Posts: 388

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

  • SocksSocks London, UK.Member Posts: 12,822

    @Tosanu said:
    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) . . .

    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 . . .

  • TosanuTosanu Member, PRO Posts: 388

    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?

  • Gamelover456Gamelover456 Member Posts: 378

    @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

  • TosanuTosanu Member, PRO Posts: 388

    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?

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    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.

  • TosanuTosanu Member, PRO Posts: 388

    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?

Sign In or Register to comment.