Hi! So I’m trying to figure out how to use “mouse button down” to destroy the static mesh component of my actor when click on it. I have to specifically use this as it’s in the assignment brief but I can’t find anything anywhere to help me with this. PLEASE!! I have 4 random spawners releasing different colour balls and the aim is to destroy one when I click on it and then it and I get a score based on whichever one is destroyed. If you even know any good tutorials that explain a way to click and destroy using the “mouse button down” that would be great thanks. Please I really need help the project is due soon and I’ve no idea how to do this!!
Edit: after reading @Everynone post, I realized I didn’t mention, that the example above should be inside your character or pawn.
So I’m trying to figure out how to use “mouse button down” to destroy the static mesh component of my actor when click on it.
- in the Player Controller
if you don’t have a Player Controller (make one!), somewhere on BeginPlay instead:
- in the actor you want to click:
Another good way of clicking on things is to use Left Mouse Down input in the Controller / Camera Pawn and Get Hit Under Cursor by Channel / Object.
However, you will not be able to Destroy Components unless you start casting to call an event inside the actor or use a blueprint interface.
The thing is that OP is not destroying actors. They’re going to click on the skysphere and pooof, gone ;p But yes, doing it in the Controller is by far the most convenient and flexible method.
Hi so I’ve put the bottom part of this explanation in apple and lemon’s blueprints. The aim is to only destroy the one I click on. The photos are just what I have so far. Do I put the top part in the player character?
I tried something like this before and for some reason it wasn’t destroying the one I clicked on it just destroyed a random one every time
Why not just try the stuff I suggested? Since you have so many fruit, the script should be in the base class so you do not need to duplicate it.
Do I put the top part in the player character?
In the player controller. But there’s nothing to put, it’s a tickbox you tick.
Thank you so much it’s working great. I get some error warnings when I stop it but I assume that’s because I’m destroying the static mesh. Thank you!!