How can you make an object (a character for example) disappear if hit by an object (ex. Obj1) but not disappear if hit by anything else? I tried to use the “destroyPawn” function but every time I quit the simulation it gave me an error
What error did you get?
What’s the purpose behind the actor disappearing? The more detail you give us the better the answer.
Usually you have to scream Abracadabra really loud.
And don’t forget to finish with a Ta dan.
What you probably want is not destruction but to toggle visibility.
The “injection” code would need to be into the object.
The character should have a blueprint interface assigned for this, and an implementation of the call that toggles his visibility.
Once thats set, you can simply detect collision on the object by changing the collision preset to cause a Hit on the character (Set to physics and query).
This generates events you can use in BP.
Within the event on the object you check what actor you hit, you check if they implement the interface, and if they do you call the disappear function.
At that point the code within the actor is triggered, and whatever you assigned to that function will happen.
Fairly straightforward, if a bit advanced due to implementing the interface.
Presto. Thats also another thing you could scream after the disappearance.