How do I make a bounce effect similar to the one in the Bullet behavior using CustomMovement?

0 favourites
  • 6 posts
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • I'm using CustomMovement for my bullets in my game instead of the Bullet behavior for the added collision control with steps (without it any extremely fast bullets go through walls and stuff) but I can't seem to figure out how to replicate the bounce effect.

    Any tips?

  • Create something like this:

  • alextro I don't want it to be random though. I want it to bounce at the correct angle similar to the bounce off solid option in the bullet behavior.

  • Of course. You just need to calculate it's bounce reflection angle.

    On collision set angle to: bllt.Angle-((bllt.Angle-wll.Angle)*2)

    dropbox.com/s/hpqmn0yuatjyhff/bllt_bounce.capx

    *By the way the default wall angle rotated 90 degrees to ease the calculation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Unfortunately this requires walls to have their angles be the determinant in the bounce calculation, which doesn't work for tilemaps. It also doesn't work for sprites that are collided from all sides and not just the ones the angle calculation would determine the bounce for.

  • You'll still need to find the angle of the surface. This is often called the collision normal. Construct calculates that internally to some extent for the bounce and the push out. But besides that you'll have to calculate that yourself.

    However, why not just use the bullet behaviors bounce? No need to replicate it. You can add it to the object but have it disabled. Move the object with custom and when you want to bounce do this:

    1. bullet: enable
    2. bullet: set speed to custom.speed
    3. bullet: set angle of motion to custom.angleOfMotion
    4. bullet: bounce
    5. custom: set speed to bullet.speed
    6. custom: set angle of motion to bullet.angleOfMotion
    7. bullet:disable

    Or at lest something along those lines.

    You can go the other route of finding the normal of a collision, but you'll have to calculate that per shape type which can add up. Or you can guesstemate the angle by sampling a bunch of points around the object's edge and averaging the overlapping points, but that's a rough approximation.

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