motion actor on *Y* for other actor

Non-platform specific questions.

motion actor on *Y* for other actor

Postby Romol » Mon Feb 09, 2009 11:54 am

motion actor on *Y* for other actor :)

I do the ping-pong . such problem! how I do that enemy (the stick) moved for ball only from up and down , not moving to the right and to the left? :cry: :cry: :cry:
User avatar
Romol
 
Posts: 35
Joined: Mon Feb 09, 2009 11:41 am
Location: Russia
Score: 3 Give a positive score

Re: motion actor on *Y* for other actor

Postby Kalladdolf » Mon Feb 09, 2009 2:46 pm

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.*
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: motion actor on *Y* for other actor

Postby Romol » Mon Feb 09, 2009 8:03 pm

Thank you! has rescued! Thank you! I now lucky person :lol: :lol: :lol: ! itself I in general write can not languages , :cry:
User avatar
Romol
 
Posts: 35
Joined: Mon Feb 09, 2009 11:41 am
Location: Russia
Score: 3 Give a positive score

Re: motion actor on *Y* for other actor

Postby Fuzzy » Tue Feb 10, 2009 3:24 am

Kalladdolf wrote:*Apologizes to fuzzy for using if(), I just thought this would be the easiest solution without confusing people.*


That is the perfect time to use if()! Well done! Good job on the comments too.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron