How do I work out the direction of a bullet?

0 favourites
  • 7 posts
From the Asset Store
Bullet Effects
$2.30 USD
50% off
This pack contains 10 types of bullet effects, with different shapes and colors.
  • 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.


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

    changes to

    ball.Bullet(AngleOfMotion+360)%360 >270

    Many thanks to R0J0hound in for the info.

    If anyone at all would care to explain how (ang + 360)%360 works I would appreciate it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)