I have set up a simple scene with a few blocks laying around, I have one weapon for shooting and destroying blocks and one for picking them up and moving them around, for the weapon that picks them up I want to highlight the blocks when I’m aiming at them, but for the gun that destroys them I don’t want the blocks to be highlighted, so far I’ve written a simple script using OnMouseEnter and OnMouseExit, but because the script is on the blocks themselves both weapons highlight them, and I have been unable to find a way to get this function to work the way I want it to, any help would be greatly appreciated, thanks guys.
Hi @SteveOranj
This question is not actually specific to your weapon - but the question is about several smaller tasks, which would have been better asked separately… (and these have been asked and answered already)
You want to get object you hit. That’s one thing.
That can be done using raycasting. You can limit what you hit using layers, or by tagging your objects, and only process certain objects.
Instead of having your script in blocks, it should be in your gun that has this feature.
For raycasting, see (or just google for x amount of tutorials and posts):
Second question is highlighting. You should call from your raycaster hit objects toggle method; when hit highlight, when cursor/whatever pointer is moved away, disable.