How to Make a Character Bounce Back When Colliding With Enemy

I don’t know exactly how to do this… I figured I would use something more controlled than useing the bounce in the physics place. I’m pretty sure the trick is something about using the enemy’s x and y position, and changing it into rotation so I can add 180 degrees so it’s in the oposite direction, then using the impulse behavior? Here is the link to my game:https://flowlab.io/game/view/1754998 P.S. I haven’t edited the sprites, you might need to check their names. Wolves=enemy Wizard=good guy that I want to bouce

2 Likes

Here’s what I recommend:
On collision >> Set angle to -45
I
V
Get (3-8 velocity, depending on density, mess around with it), velocity forward.

Make sure to have the movement keys disabled when it hits something bouncy, or the velocity will override the bounce speed.

1 Like

Yep, so I’d recommend adding switches to the left and right key if you’re using the default run and jump bundle.

Just hook 2 inputs to the bundle, on and off.

I made a mechanic like that a while ago, it’s nothing fancy and could probably be done better but it works.
Just go into the player object and then look for the knockback bundle so you can copy and past it in.

1 Like

Thanks for the help! Since I’m new to the forrums, could one of you tell me how to answer other people’s questions?

2 Likes

Just click the reply button and type what you want?

Try to stay away from being off-topic unless you’re on the Off Topic Channel of Destiny.

Once you have learned enough about flowlab, people will start asking questions that you know, like how to do bounces. When you see one that you know, feel free to answer it. More experience reaps more knowledge.

1 Like