# How to handle collisions outside of physics with bounce?

0 favourites
• 6 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.
• I am unsure how to do this, I am trying to use the custom movement to handle simple collisions with bounce, I know I could make something using trigonometry but last time I did something with manual physics it always gave me some performance issues. And I ended up going back to physics.

• A bounce is basically done after a collision. Basically the steps are:

1. check for collision

2. resolve the collision by moving the object out of the other so it's just touching

3. find the angle of the edge of the object where the object's touch. This is the collision normal.

4. using the normal calculate the new velocities. This can be done with the angleOfMotion and the normal angle, or with the xy components and some vector math.

2 and 3 are the more involved ones. The simplest for 2 would be to just move the object backwards till it's not colliding. Calculating the normal with 3 can either be done with detector sprites to get a good approximation or you can do some math with the object's geometry (typically polygon or circle) and calculate a exact normal. Another way to handle both is to use SAT (separating axis theorem).

• well, I tried to do it but it will take more work, ive placed it to the side for now as it was giving me a headache.

• I too would love to see an example for this.

In my case, I am trying to simulate gravity (without using physics) for a football object.

Thus, when the pointy side of ball touches the "ground" it surges and swirls forward (or slowly rotate backward-when .dx is slow) + loses momentum till it halts, much like when using physics.

• You can search my posts and I have made several different examples of doing physics with events. None are comprehensive, instead they focus on doing certain things.

In the example you're giving it's probably easier to use the physics behavior instead somehow. Unless you have a convincing reason not to.

But hey, if you really want to you can do it yourself and the rules above would work somewhat. It becomes a little more involved since the football rotates. As part of resolving the collision you'll want the point and normal of collision (you can have multiple points with complex terrain). The next but gets slightly more involved. Basically you apply an impulse at that point onto the ball which will result in linear and rotational motion. You'll also want to consider motion perpendicular to the contact normal and apply a friction impulse. There's guides elsewhere online that have the formulas you'll need.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• R0J0hound Thanks!

Catching up to speed with your [BEHAVIOR] Chipmunk Physics. Perhaps this is what Itenimum1 is looking for.

• 6 posts