How can I check whether or not two specific actors have collided? I have a projectile, and I want it to play a sound, destroy itself, and destroy the enemy when it is hit. Im not quite sure how to detect when an actor is hit/collided with another specific actor.
Collision: Collision | Unreal Engine Documentation
For the rest you need some easy Nodes like:
- “Play Sound at Location” or something like that
- “Destroy Actor”: Spawning and Destroying an Actor | Unreal Engine Documentation
some Events like:
Added to the list made by Diat funa, i invite you to start a fps project and have a look at the projectile in it, which is a basic working projectile.
Thanks for the responses guys! Unfortunately Im still unable to figure it out. There has to be someway that I can compare whether a certain actor, for instance a ball, collides with a specific actor, like a box, and from there play out the rest of the actions such as making the box disappear and play a sound.
Use tags. Tag the Box “Triggerbox”, say.
For example, for the OnBeginOverlap for the ball, do an “ActorHasTag” check and put “Triggerbox”. Feed this to a branch node. Now OnBeginOverlaps will only fire (from the True pin) if the overlap occurs with an actor who is properly tagged.
I use these all the time for meshes which interact with my player character differently than NPCs, for instance, since both are on the Pawn collision channel.
Once again, gives this a try. It will be a short time “learn and use” :
Migrate the projectile blueprint form a fps starting project to your project.
From the overlap “collision component” you will set what you want, “play sound” / “play emitters” and conditions based on your event outputs.
Then look at the character settings in the same fps project : the “attacking” one (i assume on lmb" but not sure).
And look at the anim blueprint to see how link anims to have it working.
You will have to change initial position math (if you use it for a tpp character for example) and change your anim settings (to use your own or the ones from anim pack) in both anim graph and event graph but you’ll have it working and modifiable as you want.
There has to be an easy way to do this. Back when I used gamemaker (remaking the same game with UE4), using GML its a simple as
if (ball.x == box.y) destroy.instance
or something like that. I just want to know how to check whether the ball has hit the box, and if it has, then destroy both the box and the ball.
Shirk, buddy, you’re not using that “Actor Has Tag” node properly. You need to connect the “Target” pin to the Object pin coming out of the Event Actor Begin Overlap node. Otherwise, the overlap message occurs, checks whether the BALL (the owning actor) has the tag Triggerbox, and goes from there. You don’t want to know whether the OWNING actor has a tag, but rather whether the actor it COLLIDED with (or overlapped) has a tag.
Incidentally, this uses overlap messages; if you’re looking specifically for COLLISION (as in, physics collision, rather than one actor crossing another one; which one you use depends on the specific circumstances of what you’re doing), you’d do a similar thing but with the Event Hit message rather than the Event Actor Begin Overlap message.
How can i make a spawned actor’s hit even activate when ever it hits ANYTHING? as of right now im casting to a npc character but i also want it to fire when it hits any static mesh also?