How do I replicate the bounce off behaviour with events

0 favourites
  • 3 posts
From the Asset Store
Bounce the ball and try to keep it bouncing and prevent it from falling down for as long as you can.
  • So bullet has a nice behavior where it bounces off an object, using its angle of motion and the angle of the object that it's bouncing off.

    However I've been trying to make a pseudo-3D game in which I've determined, in order for physics to not be destroyed too badly, I need to keep the x/y/z coordinates + angle of motion of the objects in variables, then pass them through a relocation pass before the objects are drawn to the screen.

    This means that I can't use the bullet behavior, since it doesn't update the object variables which state where it actually is. The vast majority of the behavior is easy to implement via events, but the bounce off function is notably more complex. For example, how do you find the angle of the object it's bouncing off of if the bounding box of the object being bounced off isn't square?

  • You could still use the bullet behavior. Just have it disabled until you want to bounce. Then when you want to use the bounce you enable it, set the speed and angle of motion from your variables, use the bonce action, then set your variables from the bullet's speed and such, and finally disable the behavior.

    If you want to do it with events, here's one way:

    1. when the object collides with a wall, move it backwards till it isn't with a loop.


    object is overlapping wall

    --- object: move -1 pixel at angleOfMotion degrees

    2. Next we need to find the angle between the object an the wall. One way you can approximate this is with detectors sprites or checking if points around the object collide with walls.

    3. Then you can bounce by setting the angleOfMotion to 2*normal+180-angleOfMotion. ... ounce.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, this looks good! Now I just need to make a few minor modifications to deal with a psudo-3D and I'll be good to go.

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