From what I got, you are trying to make the enemy actor move along the y axis according the y position of the ball actor?
That can be done this way: Put the following script on the DrawActor Event of the opponent stick actor:
- Code: Select all
if(y < ball.y - 20 && yvelocity < 7) // if the enemy player's y is above the ball's y value
{yvelocity += 1;} // accelerate by one
if(y > ball.y + 20 && yvelocity > -7) // the same goes the other way round.
{yvelocity -= 1;}
7 and 1 in this code are specific speed values I used in this case to make the opponent look human, you may change them as you like.
20 is a distance the actor has to keep from the ball before moving, otherwise it would look pretty odd and wobbly, and the enemy almost wouldn't be able to lose. If you make the value bigger, the level will be easier, if you reduce it though, the enemy will give you a rough time.
And welcome to the GE forums.
*Apologizes to fuzzy for using if(), I just thought this would be the easiest solution without confusing people.*