Collisions - I just can't get them working! PLEASE HELP!

Hi All,

I am spawning in actors and have collision boxes on their geometry - i also have “BlockAllDynamic” set on the static mesh component - but they just fly through eachother - I am using a mouse control to move the objects around in game, i have a snapping mechanism working using collision spheres that are also part of the actor - and this seems to work fine - i can’t work out why it isn’t working for the static mesh “body” though…

this is what the collision setting on the static mesh is:

As per this pic you can see the objects can still simply occupy the same space and float through eachother:

The following BP is how objects are spawned:

Here is the static mesh:

bump

I really need some help here everyone…

in the spawn actor node try changing collision handling override to “always spawn, ignore collisions” if it didn’t work try the rest of the overrides.

thanks for the reply - none of them seem to do anything - same behaviour regardless of which i choose

I tried adding an object collision channel

added it to the module chassis - again nothing

is it getting confused because there are multiple collision objects being handled in different ways?

the spheres are BP instances that contain a single collision sphere object - they are used to enact the snapping behaviour between the modules…the cube there is the collision box for the module body itself

Is the collision on the static mesh? If so, is the static mesh set as your root component? The bounding collision for your entire actor must be set on the root component, usually with a capsule component. But if you only have one static mesh, then just set the static mesh as your root component. If the root component has no collision and physics isn’t enabled, they’ll just pass through each other with no events regardless of the collisions on sub components.

Also, both actors must block each other’s object type for collisions to work.

1 Like

yessir

both actors are instances of the same BP - so they SHOULD block eachother right if (as above) they are on the same object collision channel?

If the box component is your collision (you opted to not put a simple collision on your mesh for example), then your box component should be your root component.

BTW, is there a reason you opted to not put a simple collision box on your static mesh?

edit: I’ll add further explanation.

Usually, yes. But in your case, no. Usually, there’s a simple collision primitive(s) set on the static mesh and the static mesh is set as the root component. In your case, it appears you don’t have a simple collision set on your static mesh. Since these are set as the roots of your actors, they will pass right through each other since there is no collision to speak of.

UE uses an optimization where it will use the collisions on the root components to do initial collisions. If there’s no overlap (as in your case where there’s no collision boxes at all on the root), there will be no collisions at all.

But if your root component does have a collision and so does the other actor and they intersect, then the engine will do more precise collisions between sub components if those components have their own collisions.

Interesting - these objects inherit from a parent (BP_Base_Module) which has ALL of the logic for the module behaviour - I also included a blank static mesh component on the parent:

the BP_Base_Module is never directly called - or instantiated - if i remove the static mesh component here (which is always empty - contains no mesh) might this fix the issue?

The reason i am asking before trying it is i suspect it will break a lot of stuff if i remove it and fixing it will take quite some time - keen to understand if this will resolve the issue before i embark on that journey…

As you can see here that “empty” static mesh component at the top is populated with all of the bits needed - including the actual mesh for the module, the col spheres that are used to handle “connection” etc…

Actually it seems i can’t delete it…

Is there a way for these objects to inherit from a parent class (so they are “all the same” from a logic perspective) without doing this inheretance thing?

Hold up… I just noticed you have another static mesh component in your hierarchy.

I didn’t quite understand what you meant by this. I mean, at this point, you need to ask yourself some serious questions about what you’re doing. LOL Why would you do it this way? Why do you have an empty root component that’s a static mesh component?

I’m going to give you a quick breakdown on the proper way to do this. The first question is this. Are the spheres needed for collisions? If no, do Option A. If yes, do Option B.

You can duplicate your blueprint in the content folder by right clicking on it and select duplicate to test this first.

Option A (This is the usual workflow for static meshes):

  1. Click and drag your static mesh component that has your static mesh geometry onto the root component. The root component is the second item listed in the hierarchy.
  2. Drag any children of the empty static mesh over the root component.
  3. Delete any empty static mesh component. If they are not the root component, they can be deleted.
  4. Delete the Box component.
  5. Add a collision box to your static mesh component. (Do NOT add a component. You add the collision box to the mesh asset).

Option B (You have multiple things in your hierarchy that you want to distinguish collisions with):

  1. Click and drag your Box collision component to the root component. The root component is the second item listed in the hierarchy.
  2. Drag any children of the empty static mesh over the root component.
  3. Now you can delete the empty static mesh component.
  4. Make sure the collision of the Box component is large enough to fully contain all the spheres. Yes, make it bigger.
  5. In your static mesh component that actually contains the mesh, add a collision box that only encompasses the mesh. (Do NOT add a component. You add the collision directly to the mesh.)
1 Like

Hi yeah the spheres are needed to detect when the module is able to dock (and snap) to another module - effectively when the spheres overlap you can snap them together (by holding down shift)

So option B is the goer:

image

Seems I cannot do step 1…

Interestingly collisions DO work between the player pawn and the modules - i cannot “fly” through them and bounce off if i try

You are asking me “why am i doing it this way?” a great question but it was the only way i could work out how to get modules of different sizes to snap together - i followed a video series that was kindly referenced by another user: https://www.youtube.com/watch?v=AgXbXoSRqyI&list=PLGm9gBuuMTeuLQythBu61WK7qO31RRH7l&index=1

Which on the surface is quite cool - however because it uses the size of the collision boxes and the sizes of the static meshes to handle the snapping it will not work for me - my modules can be any size and shape and the solution provided by this video series requires the collision boxes to always be the same size as the objects snapping to them..

So question here is why does it not allow the pawn to go through it? but it does allow eachother to go through?

It does have the collision object on the root node as you’ve suggested I do - but I am unsure how to do this without having the collision object always be the same size - unless of course i dynamically change it…

What’s the base class of your actor where you have the static mesh?

I watched a bit of that tutorial. They use a Static Mesh Actor. If that’s why you can’t drag onto the root component, then you need to set the mesh of the root node to the mesh you want to use. Right now, you have the mesh set on a sub component. So this part, you are NOT doing like in the tutorial.

Well, that can be made to work. It was likely done with fixed sizes to make the tutorial easier to follow. You just need a socket on each actor to know where to snap to. Usually have a similar naming convention to your collision boxes so you know which socket to use for snapping. IOW, the boxes are for collisions, the sockets are for snapping.

If I were to guess… probably the spheres are stopping the pawn because those are separate actors.

Here’s how collisions work. Both objects need to block each others object type. If you want self blocking, it’s easy. If the Object Type is WorldStatic, then you need to block WorldStatic. This will block each other. But there MUST be a collision mesh on the root component. Right now, you have none. We’ve gone over this above. I won’t rehash that here. Just copy the mesh to the root component and continue to step 2.