I have an actor called meteor spawning into the level from the sky, how do I make it so when the meteor hits the ground the meteor gets deleted, but when it hits the player it goes to a different level?
You want to add a hit event to the mesh in your blueprint. When it hits something check if it’s the player and act accordingly.
Edit: I’m pretty sure you also need to enable simulate physics and simulation generates hit events for your component.
1 Like
Thank You!
is there a way to ignore a certain object so it won’t be destroyed when it hits it?
You have a few options to do that.
- The first and most taxing way is to Cast the hit actor to your player, or compare the actor to a GetWorld function like GetPlayerPawn. In a similar way you could create an array of actors to ignore, expose it in the editor, manually drag the references in, and then on begin play call Ignore Actors When Moving and specifically ignore those actors. Or do the same thing with an array of actors to specifically respond to and compare them when you collide.
- Use a collision layer, by adjusting the collision profile of your meteor object and your target objects you can ensure it won’t collide with some types of actors, and will with others. You could potentially sort reactions based on a ‘Hit’ result and an ‘Overlap’ result by blocking some layers and overlapping others. If the default system is insufficient you can create unique layers for however many different types of actors you need.
- Use a tag check, place a tag on your actors and then compare the tag when you collide with the object. This is also very taxing as String.Compare is a very expensive operation. I recommend instead creating an Enumeration to compare and accessing it through an interface as these are much much faster, but same theory different application.
- There are more. These are just the 3 I personally see all the time. I recommend a combination of 2 and 3 using Enumerations. 2 covers 99% of your interactions, 3 is for specific planned actions.
ok, thanks!