Removing collision via script doesn't work for actor

I made an editor utility script that is supposed to remove the collision of an actor in the scene, but the cast fails, and I tried it with an actor that had a static mesh. When I tried to do it with an asset instead it worked though. What’s did I do wrong?

It fails because you’re casting actor to a static mesh asset. The cast tests if the actor IS a static mesh, it is not.

Actors own static mesh components that have a static mesh.

How do I get the actor’s mesh then?

Or is there a node for getting a pure mesh(that isn’t an actor) in a scene? I’m not sure what the best solution is here.

Again :), actors do not have static meshes. Actors have Static Mesh Components that have static mesh objects assigned to them.


If you know the static mesh component is at the root of the actor, you could:

If it’s not at the root or there’s more than 1 smc, you need to look it up first. For this you need to know which one you want, and only you know that.

This actor has 5 SMCs, each can have a static mesh:


When you drag a mesh from the Content Browser and place it into the scene, the engine creates an actor + static mesh component + static mesh automatically. This is called a StaticMeshActor but it’s still an actor with the above setup:

image

If that’s what you’re using, the suggestion at the top of the post should work. Other than that, we’d need to know more about the hierarchical structure of the actors you’re selecting.

1 Like

I think it could work, but how do I create the target-root component node? And the one after the cast if it’s not automatically in the list.

I also haven’t seen the cast node you’re using. It has a success node instead of a failed node…

create the target-root component node

No tricks here:

Converting cast to its pure form is optional - right click it:

Since we cast to SMC, get the mesh in the typical manner:

I had to untick context senstive to find it. Anyway, I did it like you showed me but the cast still fails for some reason I don’t understand.

There is no static mesh component as the actor root then. Again, it’s impossible to advise without knowing more about the:

we’d need to know more about the hierarchical structure of the actors you’re selecting.


  • this would fail:

image

  • while this should work fine:

image


image

at the root, because that’s the only place where we’re checking.

If it’s not at the root or there’s more than 1 smc, you need to look it up first.

Like so could work in this case:

Again, the crux is in the details.

Drag the wire first, then search. BPs are context sensitive for a reason - it filters nodes that make sense in this context and helps avoiding mistakes. Avoid plopping down orphaned nodes.

If you cannot find something with CS checkbox enabled, you’re probably looking for the wrong thing in the wrong place. Or there is a much easier / faster / better way of getting it by dragging the right wire first.

Now it works and I understand it better now. Thank you.

I had the regular actor + a static mesh attached to default scene root.

Screenshot 2023-10-22 144733

But I noticed a small issue, depending on what you want this to do. The tool removes the collision from the actor in the content browser too. Is there a way to only remove the collision on the actor in the scene? I assume that’s an instance of the actor?

1 Like

They did not. It’s just naming conventions that are not that great. It’s a static mesh component that by default is named just Static Mesh - confusing:

image

vs

Probably because they are all components - that’s the nature of actors. Calling all of them component might be redundant. Same with:

It’s can be a tad confusing.

Yes, you’re doing it to the asset itself. And yes:

Disable collision on the component itself, not on the mesh. Now it will work on the per instance basis.

Tried it with a basic cylinder but it doesn’t work unfortunately. The collision is still visible and the player is definitely colliding with it.

Just confirming the suggestion works fine on my end. Could you post the script you’re using?

Looks exactly like your suggestion, unless I missed a tiny detail.

I run mine off a utility widget button click. You’re using a utility blueprint Actor? Asset action utility? Not sure why this would make a difference, though. How do you trigger all this? How does it work? What is it?

image

It also works via the utility Run:

Awkward to use, but seems fine.

I just made a new function, so I have nothing in the event graph. I run it by right clicking the actor like this:

The actor is a basic cylinder created from Shapes->Cylinder in the editor. I don’t know what a utility actor is, but it needs to work on all actors, because it’s made with the purpose of making work easier for a level designer. I suppose I could make a widget too, but that’s the second task we have and we need to make two unique tools.

How do you run it with “Event Run”?