Shield collides with own ship when going too fast

Hi all,
I’m making a spaceship with a shield.
I have a static mesh component for the spaceship, which I use as root.
I also have a child component which I use as shield.

It blocks shots and collides alright.
The ship moves and the shield is always around it, stable.

Everything works really fine, until I accelerate very fast.
The shield starts colliding with the spaceship mesh.
I am sure about this, as I printed out the Hit Component from the OnHit event of the shield, and it’s the mesh of the ship.

Of course, if I disable the collisions of the shield, the problem disappears.
I also noticed that if I make the shield ridiculously big compared to the ship, the problem disappears.

What is this due to?
Errors in position calculation?
How can I solve this, in a way where I can accelerate freely and at the same time keep a shield of reasonable size?

Thank you!

That does sound strange.

However, a quick solution would be to get your shield’s collision component to ignore the ship mesh. You can probably use the collision channels and add the collision channel of your ship to the shield’s ignore list.

Hi mindfane, thanks for the suggestion.

I also found that method.
The issue however is the following: as I plan to have multiple spaceships with shields, this method cannot really work for all together at the same time.
For example I could define a “shield” collision category, which does not collide with “ship” collision category.
However then no ship would collide with any shield, which does not work game-wise.

I also found out another thing: if I make the shield small enough, it just keeps colliding with the ship without even having to move.
Is there maybe trouble with a collision mesh?

I also just thought to remove the shield altogether and just “simulate” the presence of a shield through blueprint and shaders.
This would certainly work, but I would like to understand what’s going on and fix this issue.

One possibility I was thinking about, was that some position calculation errors were causing this issue at high speed. I also used the ‘update world zero’ option (can’t remember the exact name), but this doesn’t help.

I also added a physics constraint between ship and shield, ticking the option ‘ignore collisions’ between the two elements, but also this doesn’t help.

One additional point: I am using physics simulation.
Maybe physics doesn’t like attached child components?
Maybe there are some micro-stutters when moving that trigger physics when two objects are somewhat close, especially when the levels are very large, like in the case of a space sim?

No clue :confused:
Any more suggestions? :slight_smile:

They don’t always see eye to eye, true. And simulation at high velocities is unreliable by default. See if one of these works for the Actor hosted by the CAC:

image

I’d start with Post Update Work but an earlier step might work well enough. fingers crossed


[edit]: or is the shield just a Static Mesh Component and not a Child Actor Component hosting a Child Actor?

I also have a child component which I use as shield.

Could you clarify? As in:

image

Static Mesh Component has a Static Mesh.
Child Actor Component holds onto an entire actor with its own components, logic and variables.

Also, for high velocities, it’s worth fiddling with those:

Do read their extended tooltips (Ctrl + Alt) before cranking it up real high.

Also, there’s this:

image

I know it exists but never used it, sounds like it could work here! You may want to reverse it, depends on who collides incorrectly with whom.

Hi Everynone,
excellent help, thank you.

Let me clarify:

  • My spaceship mesh is the root component of the Spaceship blueprint
  • The shield is a child component of the spaceship mesh root component

This I choose because certain functions become easier.
For example if I use “get actor location”, I used to get the right location for certain objects only if the root is the static mesh.
For some other objects is seems to work fine. I still have to wrap my head around this side issue.

Anyway.

I switched to “post update work” as you suggested, just for safety.
I did not change the iterations of the solver. This looks very resource intensive it probably would break the game performance, if replicated on many objects.

In parallel, I found a solution which seems to be working fine!
I found this article: Some Tips to Using Physics in Unreal Engine 4 - bright developers

Here they explain that, when using physics, you must ignore all collisions.
Sounds crazy, but actually it seems that the physics engine will take care of collisions by itself.

Once I switched the collision off, there were no more collisions between spaceship root mesh and shield child mesh.
I tested then with two objects: an asteroid from a blueprint with physics enabled and a simple sphere with physics enabled.

The asteroids collides with the shield and bounces away as it should.
Regarding the sphere…there’s no collision, although I enabled its physics.

I will now have to find out why the sphere doesn’t work and how to fix it.
But hey, the original issue is solved and now I have a smaller one which seems surely solvable :slight_smile:

Edit: by clicking repeatedly on “simulate physics” and “simulate hit events” I managed to convince the sphere to participate to the physics simulation xD
Not sure what was the problem. I will likely create a general blueprint for planets to make sure they always have the same physics parameters, then switch between textures with an index, or something like that :slight_smile:

It’s not crazy, it’s simply not true. :slight_smile: There’s some confusion here. You can’t have physics simulation with no collision, for example:

  • above, I’ve removed collision from that cube; it will never simulate physics on its own. That’s unless it’s attached to something that does have collision and is simulating, here - the root. That’s referred to as welding in UE4.

Do note that having and using collision are 2 different things!

Simplified is used for physics sim.


In your case you had a root mesh simulating physics and an attached Shield Static Mesh that also simulates. The latter can have collision but should not be simulating physics separately. That’s the job of the root component to account for the welded on component:

In short:

  • root static mesh (yellow small box) - has collision and simulates physics
    – shield static mesh (big box) - has collision but does not sim physics

The yellow box is using its own & the blue box’s collision when simulating. This way, theoretically, those 2 entities should never interact with one another (unless overlapping ofc) but can interact with the world using their own collisions.

Very interesting, thanks a lot for the explanation.
Now I get why the child actor component has many less setting options.

Just to show how I’m setting it up.
“Simulate Physics” is ON.
This is the collision window of the spaceship root static mesh component:

What is weird to me is that I set everything to “ignore”… but I have collisions. And it seems that other bodies, external to the blueprint, require Physics enabled in order to collide.

Maybe the topic here is between these “Query” and “Physics” collisions?
Meaning the Query collisions are the ones controlled by the tickboxes, while Physics collisions are always present?
I’m totally new to the engine, so I’m trying to understand how it works in detail :wink:

Not from this element. With this setup you can simulate physics but this element will not collide (or be collided against) with anything. Nor will it generate Events.

If you’re receiving hits, they’re coming from another element - print the name of whatever is generating them to find out. Is there something attached to that root, the shield perhaps?

The yellow is simulating but ignoring all collision responses:

The blue is blocking. Since yellow cannot use its own collision due to the, ehm, Ignorance, it will use blue’s instead. The blue is a child component of the yellow.

Oh no. That means I “solved” the problem just by switching off collision altogether :confused:
Only the shield is getting ‘hit’ events.

One thing I noticed: my shield mesh is a Child Actor Component, not a Static Mesh.
This is because I need the shield to perform its own actions on events.

Could this be causing the trouble?
Maybe the Root Mesh and the Child Actor ‘dislike’ each other?
Maybe there’s a better way to do this?

Edit: I turned collision back on for the ship. The issue of the collisions with the shield came back.
I tried to enable physics on the shield Child Actor. Now the shield is this funny oval which bounces around, completely unbound to the ship, causing continuous collisions with the ship itself, which is trapped inside :slight_smile:

The longer I think about it, the more I’m convinced there’s no easy solution here. To sum it all up with a one liner:

You’re looking for a way to disable physical collision between a pair of entities only, while everything else can still collide with them. Is that correct?

  • ship
    –shield

These two ignore each other’s collisions. But ship+shield must interact with all other ship+shield pairs.

  • collision channels only work for groups (so no use here, me thinks)
  • Ignoring Moving Actor / Components won’t crack it - I had a look at what it does and it’s a weirdo Sweep that has nothing to do with physics
  • the more nuanced bits of Apex are not exposed to BPs
  • I’ve yet to touch Chaos - I’d like to think it’d provide this kind of granularity

A bit stumped by this, I admit. If I’m missing something obvious, that’s on me. Sorry I couldn’t
help.

If I get a lightbulb moment, I’ll report back.

Making a hollow sphere would probably work but that’s a bit silly. Since you mentioned the ship rattling inside a hamster ball, I’m assuming that’s the end goal here.

Yep, that’s a good summary of what I’m trying to do.
Works fine at lower speed, but this issue appears at higher speed only.
Looks to me it’s a limitation of the engine, likely some inaccuracy in the calculation which is sufficient to make a mess.
In fact when I make the shield ridiculously large (like 20 times the ship) the problem disappears.
The problem is stronger, the smaller the shield is compared to the ship.

Really sounds like calculation inaccuracy to me :slight_smile:

I will just change method.
I will start by making the shield an actual static mesh around the player and see how that behaves. I’ll have to re-blueprint quite a bit, but it’s entirely doable :slight_smile:
Another funny approach can be to “pretend” to have a shield which is just above the hull and show a shader when the hull is hit.

Both are funny experiments to try out, although as a beginner I’ll likely take a while to get them to work xD
The important point is that I can reach a stable solution which I can then replicate on N other ships without further rework :slight_smile:

Thanks a lot!
In case any other ideas pop up, I’ll be happy to try them out :slight_smile:

Hi,
CCD was not enabled. I now enabled it and the result unfortunately is the same :confused:

I have a pre-made blueprint which I downloaded, so this is the setup I have so far :slight_smile:
The nice thing is that the shield is its own actor, with its own health and such.
One can just change the ship and then slap the shield Child Actor onto it and have it work right away.

Now I’m trying to add a Static Mesh as child of the ship, to represent the shield.
I have to code a bit more to make things work :slight_smile:

I noticed one additional thing.
When I travel at ludicrous speed, like 1M, I see the mesh of the ship having many rendering glitches. It becomes all blurred and some faces are definitely not okay.
It seems to happen also to the collision mesh, if I visualize it.
I can see that blurred collision mesh and blurred ship mesh touch each other often.
This might be the source of the issue. Likely some calculation errors when you go too fast.

I have now implemented a simple shield using a child Static Mesh as I wrote above. Works perfectly and the problem is solved.
For those reading in the “future”: avoid attaching a Child Actor component with collisions (like a shield) to your Static Mesh root component (like a ship).
Better to use a Static Mesh as child also for the ship, and do some coding into your ship to manage the shield :slight_smile:

I’ll see later on if this is a sustainable choice for other ships as well :slight_smile:

Providing I understood you right and this:

is the case, my bet is that it can’t be done in BPs as is, and it is the reason for this plugin to exist:

It seems to be doing exactly what you’re looking for. On the other hand, you can always change the logic of what you’re trying to achieve.

I imagine it as 2 overlapping bodies:

Where the smaller one simulates physics and the CAC’s actor also has a static mesh that must collide with everything bar the CAC’s owner.

But somehow I feel I missed the point of this exercise :expressionless:

Ah that’s interesting!
That’s exactly what I was looking for at the beginning of the thread :smiley:
I’ll keep it bookmarked if I come up with some similar but more complex issue which I cannot solve in BP :slight_smile:

So far I managed to reproduce the same behavior of the shield by using a mesh and some BP nodes, so in the end the mechanism is the same as I wanted, just with a different method :slight_smile:
I actually prefer this method, as I just remade the nodes and simplified them compared to what I had.
I just have some issues with projectiles, but I’ll work on that over the weekend. Or open another thread xD

1 Like