How to make my character bounce against walls

Hi !
So I’m a total beginner (6weeks) and i wanted to create some level elements that will make the character bounce on hit.
I currently make him “bounce back” (relative to the characters forward vector) but it causes a few collision/physics issues as you can see here :

So the idea would be to make a ricochet bounce I guess but I’m not able to get the expected result (I tried a lot of stuff found on forums and youtube)

Here is the actor code I ended up with (a “wall” for instance)

How can I make my character “ricochet” on walls ?
How can I remove that “shaky” effect on collisions (end of video) ?
Do you have any tips at all to handle all of that ?

Sorry for my english, it’s not my first language.
Thanks !

If normal impulse is the location where the hit had place, use the hit component and other actor locations, in the 3d space and the hit location, to calculate where to launch character.


Something like that… Try that… multiply it by -1000 if does the opposite and launches towards the wrong direction…

Ot just use normal impulse if that vector is the normal of the hit itself… like that

Thanks for the help Neongho, but neither of those methods works for me, I have the same kind of result that you can see in the video (character flying backward and not a real “bounce”)

anybody please ? I’m still lost about this issue :frowning:

Try it like this:

You can give the components you want to bounce away from a tag to identify what is bouncy and what is not.

3 Likes

I don’t quite understand the whole thing yet but it works !!!
(+ I don’t have to replicate the code in every actor I want to bounce away from, which is really nice)

I’ll try a few things to be sure that I understand what’s happening here so I’m actually learning something out of this :sweat_smile:

Thanks a lot, you just made my whole week, I gotta go fast now :wink: :+1: :raised_hands:

  • when the Player Capsule touches the wall, the Hit Event may trigger multiple times as we end up sliding along the wall; DoOnce + Delay .2s ensures Hit is handled no more than 5x per second. It’s more of a safety measure.
  • tags allow to ID hit components easily; admittedly there are other ways to do it, some better than others - it all depends on how things are structured
  • OnComponentHit’s Normal is the direction the wall is facing
  • Mirror Vector explains what is does in the tooltip very nicely - shining a laser at the mirror (Normal), yada, yada…
  • GetLastUpdateVelocity - when we hit the wall, our velocity changes (we change direction or even stop completely) so we cannot use just Velocity for the calculations to find a new traverse direction. Instead we take the most recent velocity before colliding - whatever was accumulated in that vector last frame / update.
  • the multiplier should really be <= 1 but it’s more fun like this
3 Likes