I'm doing a bit of a Pong game and I am trying to get the computer controlled paddle to react a bit more that following the Y co-ordinate of the ball.
I would like the paddle to move to the middle of the screen when the ball is traveling away from it and move to the balls Y co-ordinate when the ball is moving towards it.
The ball has a bullet behavior and the paddles bounce the ball in the reverse direction. Its sprite is set to not rotate.
My problem is that I can't work out how to tell which direction the ball is traveling in. I would have thought the bullets Angle Of Motion (as per the manual) but all I get on the ball are 'Compare distance traveled' and 'Compare speed'.
Any help at all would be gratefully received.
Develop games in your browser. Powerful, performant & highly capable.
if you have "set angle" on the bullet behaviour set to on you can just compare the normal angle and if not you can use "System compare two values" for the firwt value you can then set ball.bullet.angleofmotion
Thanks for the reply though I'm not sure I fully understand it. I have set angle to random (360) to start off with and I'm not trying to set angle of motion, just trying to find out what it is. My idea is that if it is 0 degrees (+ or - 90) it is traveling to the right etc. I'm pretty much a beginner here and maybe that is not the easiest way of finding the direction of travel of the bullet object?
yeah sometimes its hard for me to explain in english
hope this picture helps you
if not i will post a capx tomorrow
Your English is great but I'm an artist so your picture is even better
Many thanks for taking the time to do this. I'll look at it over the weekend.
I think I am missing something here.
When I use this the sprite 2 only moves to the Bullet sprites Y position if the Bullet sprite is moving downwards as well.
It seems that AngleOfMotion only works between 180 degrees and -180 degrees.
and needs to be changed to a 360 range for the example to work.
So in the previous post:
ball.Bullet AngleOfMotion > 270
Many thanks to R0J0hound in https://www.scirra.com/forum/viewtopic.php?f=147&t=104112&p=779640&hilit=negative+angle#p779640 for the info.
If anyone at all would care to explain how (ang + 360)%360 works I would appreciate it.