How can I find this angle?

0 favourites
  • 5 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • So I'm basically trying to make this explosion push things outwards via physics impulse with this formula as the angle "angle(self.X, self.Y, ExplosionBox.X, ExplosionBox.Y"

    However, it pushes the objects in a very strange direction. As you can see from the picture, there are 2 lines. The line between Point 1 and 2 is the angle that the objects are being thrown at, but I would rather have an angle like the other one. How can I go about this? Is there a way for me to get the coordinates for point 3?

  • I'm not sure what line you mean by the other one. Do you mean point 1 to point 3?

    It looks like you can get point 3 with (x2, y2+radius) if that helps.

  • I'm not sure what line you mean by the other one. Do you mean point 1 to point 3?

    It looks like you can get point 3 with (x2, y2+radius) if that helps.

    Yes, not necessarily the coordinates of point 1 to point 3, but the angle. That formula unfortunately doesn't help me very much because I'm looking for the coordinate of, or the angle to the point of impact between the circle and the rectangle.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So in the picture which is the object to push and which is the explosion? Normally an explosion is round so the angle to push the object would be angle(explosion.x, explosion.y, obj.x, obj.y).

    It's possible to calculate the point of collision between a circle and a box but it's not really trivial. In your picture at least the angle from 1 to 2 is not much different than 1 to 3. I guess I'm not fully understanding the issue. Could you post a capx perhaps?

  • So in the picture which is the object to push and which is the explosion? Normally an explosion is round so the angle to push the object would be angle(explosion.x, explosion.y, obj.x, obj.y).

    It's possible to calculate the point of collision between a circle and a box but it's not really trivial. In your picture at least the angle from 1 to 2 is not much different than 1 to 3. I guess I'm not fully understanding the issue. Could you post a capx perhaps?

    Yes. That's what I'm doing. However, point 1 is obj.x, obj.y, and the line connecting point 1 and point 2 is the angle of propulsion, even though the contact point is at point 3, and the expected angle is closer to that of the line between point 3 and point 2.

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