On Component Hit - Infinite Loop

I’m using floating pawn movement to move a drone enemy towards the player. I wanted it to bounce off the floor and other objects (like other instances of this enemy), but supposedly physics doesn’t work with this component so I had to handle this manually. See the attached link.

However, when a collision happens, I get an infinite loop crash:
image

I’ve tried to solve this with a testing boolean, so that when a collision happens the boolean is set to false to prevent any more bounce collisions (to see if it was caused by on hit being called constantly), but this only fixes the problem sometimes. Every so often it will still crash.

Is there a way to fix this issue? Or another way to handle the bouncing physics that I want?

Can you tell more about what you expect from the drone and how it works / moves? Is it on wheels? Hovers above the ground? Bounce in what way? Like an elastic ball? I have a few images in my mind, all quite wild!

but supposedly physics doesn’t work with this component

Why? Or you don’t want to use physics?

1 Like

They just float around! Their behaviour works fine with the floating movement component the way I want them to, in that they’re always trying to reach the player but need to gradually turn to face them. This component accomplishes that great. However, I also want them to bounce off each other and the ground with this floaty drifty movement.

I originally wanted to use built in physics to accomplish the bouncyness, but I heard physics don’t work with movement components like character movement and the various pawn movements. I’m not sure this is true.

1 Like

I’m not sure this is true.

It’s not. It is. It’s complicated. :melting_face:

Like heavy beachballs? Like hovercrafts? Like homing volleyballs? All of the above?

You’re asking for something very specific but aren’t being descriptive enough. I’d like to help but still cannot imagine the kind of movement needed so I’ll grill you for as long as I have energy spare, even though it’s not my favourite activity here. ;p

Trying to figure out whether physics is needed to achieve what is needed and would hate to send you the wrong way.


That’s what Ive got so far:

1 Like

Here’s a video of what I have.

I’m not saying that I can’t accomplish what I’ve got since it does work, the post was about how the code I’ve written to manually implement bouncing is causing a crash. If there’s a way to have them bounce off surfaces using built-in Unreal physics, I’ll be happy to hear how I can add it. Or if you know a way I can do this that doesn’t make use of the floating movement component? Either works really!

(no idea why there’s such a big gap between the video and the text on my end lol)

1 Like

I am by no means great with the internal physics system, as I have someone who handles this for me in more complex cases, but have you tried to use a physics material applied to the actor? A bouncy ball for example could use this, supplemented with additional impulse if needed. My projectile system uses predictive line traces along with physics materials to calculate how bouncy (ricochet) the projectiles should be on surfaces.

1 Like

I tried a physics material before but it didn’t do anything. Could I have been using it wrong?

I believe it just needs physics enabled, and the surface type, restitution and density values in the physics material (along with the mass of the object in the details panel of the actor) are most of what you would really need to tweak to get some simulation going. Maybe double check the surface types of the other actors it would be colliding with to make sure they match up. I can’t recall how the default surface type for both the physics material and colliding actors exactly behaves. When I get home later, I can check that out further.

One thing to explore is the PCM - Projectile Movement Component. Turn the drone into a Homing Projectile that can bounce:

It supports homing and bounciness and lots more. Not sure how well that’d mesh with the movement system you have. Perhaps it could work. That’s the entire script btw… which gives you:

Can be made better with some tweaking. May be worth exploring. The PCM would emulate the physical behaviour here.

If you went down the pure physics route:

A physical material will open up a lot of options (as mentioned above @SteveRambo):

image

And there’s nothing to calculate.

1 Like

With Add input Vector on Tick?

Unlikely but I’ve been wrong too many times. :person_shrugging:

First of all - why do this, the whole point of Sweeping is to stop the movement before the collision happens. But you do want to move, right? Since hits can happen very rapidly as de-penetration works hard to eject intersecting geometry - the first thing I’d do would be to introduce a resetable DoOnce node and allow hits to happen no more than 10 times per second, perhaps even slower.


To get a reflected vector:

image

How to apply it would depend on how you move stuff - we still do not know that, though.


If you are using physics:

image

This vector is not normalised and scaled to mass, velocity and density (phys material) afair - but do not quote me on that.