Make player bounce off walls

Hello there friendly gamemakers and code wizards!

I am working on a top down little project and I want to make my player bounce off the walls and other objects with a similar force/speed as it collided with it.

However, it is not working. I can make other objects bounce correctly both with the bounce extension and the physics behavior. Whenever I apply the same method to the player object, it doesn’t bounce anymore, it just gets stuck to the wall instead.

I have tried disabling the controller for a fraction of a second after the collision to see if it was interfering, but it doesn’t really work.

Can someone help me?

Thank you!

Can you screen shot the current events around the player movement and attempted bouncing?

@MrMen thanks for replying. Here’s a GIF of what’s happening and the settings.

This appears pretty much identical to this one. It’s been raised, not sure where it’s at.

Is there a workaround?

Not that I’m aware of.

How are you moving the object? Can you post a screenshot of those events and the physics behavior settings? It’s tough to read them in a GIF. Make sure you’re applying force using the physics actions not the default or changing the x() or y().

Hey @Keith_1357 ,

I am moving the object using the top down movement behavior coming from the multitouch controller. It should be applying forces, according to the documentation.

Here’s the screenshot of the physics behavior.

I don’t have any events or actions at the moment.

And this is the physics for the wall:

Are you mixing top down movement and physics behaviours? Use one or the other, but not both. They don’t mix very well.

Also, if you are using top down behaviour, how can it bounce off the wall? Pressing right will keep moving it to the right, negating any bounce to the left.

Also, restitution is a value between 0 and 1 - absorb all energy and absorb no energy.

Some really good info there, thank you @MrMen !

My questions:

  1. How do I use the multitouch controller with physics? I thought that, as the documentation says that it generates a force, it was exactly thought to use mixed with physics. Can you help?

  2. That doesn’t make too much sense to me, so I beg your patience :slight_smile: My logic behind this was that if the acceleration to the right was lower than the bounce force, it would still bounce. Like if I drive a RC car into a wall, full throttle, it still bounces back, then reaccelerates to the right.

Still: if you see the GIF, you will see that at the moment of collision, the controller is not pressed.

  1. Thank you. I saw somewhere else that I should set it to >1 to see if it bounced.

Highly appreciate your help.

IDK if the top-down behavior generates forces. If it does it’s not the same forces as the physics behavior. It might be a continuous instant force instead of permanent. IDK. The top-down also generates ,or reduces a “force” to decelerate. The issue is it’s applying 2 “forces” and they’re competing. One will either undo or overpower the other. The bounce would have to be more powerful than the force being applied.

Here’s simple example using the pad and applying force. It’s a bit like flying a spaceship.

try it:

1 Like

It’s alive!!!


Exatly what I needed! Thank you Keith and MrMan!

1 Like