Hey guys,
I'm trying to make an AI character perform a pattern movement when a certain action occurs rather than have him do it all the time. I call two different methods, one to move him left, then move him right, the problem is the first method is still active when the second is called and it cancels out the movement and he stands still. Any suggestions??

How is that method still "active"? Are you creating a second thread for each movement action? Generally, if you want to explicitly move something, you would have a method set the object's speed, then the actual movement is handled each step through the main game loop. Something like this:

function move_left() {
    hspeed = -1.0;
    ...
}

function move_right() {
    hspeed = 1.0;
    ...
}

function game_loop() {
    ...
    obj.x += obj.hspeed;
    ...
}

You also shouldn't be incrementing your speed, you should be setting it. With so little information, I can't really give you any more advice. Please post some code or, at least, some details on how your handling movement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.