Download

How to check if Actor overlapped with an instance of itself ?

Hi everyone, I’m trying to replicate a mobile game where you basically have to shoot knives into a rotating circle without touch other knives like this:


The way I did it was to make the knife throwable by using a projectile movement comp, deactivating it when it hits the circle and attaching to the former circle like this:

The thing is that I couldn’t check if a knife is hitting another knife because then it saw the circle as a knife too when it collided with it (maybe because I’ve attached them ?).
I’m new to the whole thing so please excuse my stupidity :slight_smile:

What would you like to do when a knife hits another knife?

For example if you want to destroy both knives when they hit each other, you can add an overlap event in the Knife actor and destroy them, like this:

This will give a behaviour like this:

Since your overlap event is coming from ‘Cylinder’ component, it wont take overlaps from the Knives, as they are different actors with different collision components in them.

Hi mindfane, thank you for taking time to help me :slight_smile:

I did something similar to what you’ve suggested except with print string like this:


What happened is when my Knife projectile overlaps the circle it prints “Hello” twice, and when it overlaps the circle and a certain knife attached to it at the same time it prints “Hello” 4 times.

The mechanism I’m going for is to print a single “Hello” and only when a knife overlaps a given attached knife.

What is your component hierarchy for your Knife and Circle BPs? Do you have an explicit collision component?

Hi Again,
I’ll try to break down the project as much as possible to make things clear for you.

This is the result of the existing code:


This is the Knife and Cake’s hierarchy:
d

xx
I don’t really know what explicit collision means but if it means what I think it does then yes I have made my collision to be as accurate as possible instead of just boxes.
I’ve also set both the knife and cake’s collision to “Overlap All” with “Simulate Physics” set to Off.

These are the Overlap Events for both of the actors (the knife is a pawn), the cake’s overlap event is only reserved for aesthetics:


This one is the Knife’s:

Lastly (and idk if it matters) is the function I’ve used to launch the knife and spawn another one in it’s place.

Thank you again and I’d really appreciate it if you could help me solve this.

I replicated your setup and this has worked for me. Pay closer attention to the collision setup (on the right pane)

NOTE: This is UE 5 Early Access - not UE4, but I expect the behaviour to be the same.

Cake BP (I call it Disc)

Knife BP (I call it Bullet)

Ideally I would make a collision component as the root component of my BPs, such as a Capsule or Box, and add the static mesh as it’s child. However in the above example I tried it make it as close as your setup, so I used the Static mesh itself as the root.

Hi again, I’ve bothered you enough but I just wanted to say that what you’ve suggested worked. I only have 1 question left, what’s the advantage of doing this instead of what I’ve done.

Ideally I would make a collision component as the root component of my BPs, such as a Capsule or Box, and add the static mesh as it’s child

And can I add this collision component to be accurate to the mesh instead of just Capsules, Boxes and Spheres ?

what’s the advantage of doing this instead of what I’ve done

I don’t quire understand what you mean. My original attempt was quite different from what I have posted above, and I changed it to make it more similar to your setup. In my original setup I had a collision component as the root of the BP.

Collision checks against a simple shape like Sphere, Capsule etc… are a lot more efficient than against an arbitrary shape.

And can I add this collision component to be accurate to the mesh instead of just Capsules, Boxes and Spheres ?

No. But what you can do is add collision geometry for the static mesh that approximates the shape reasonably well. Then you don’t need a separate collision component. Unreal’s static mesh editor has the tools to generate this. Having such a dedicated collision geometry is advised for performance reasons.

When it comes to collisions, most of the time it is better to define the collision preset on the root element itself.

Thanks ! I’ll try to recreate the project following your way to see if it suits me better.