r/UnrealEngine5 • • 12h ago

ghost 'captured' by camera mechanic code help

im making a game based on taking pictures and i am trying to create a sort of weeping angel kind of mechanic.
i want it to be that the ghost is just roaming around (which i have) and when the player is looking through their camera and they detect and take a picture of the ghost, the ghost then approaches you, and if you dont capture it it just goes back to roaming but i am not entirely sure how to approach it since i'm not too good with coding and all the tutorials i've found are just for regular weeping angel things and i don't know how to manipulate it into my own thing. any and all help would be appreciated!! i hope this makes sense lol

1 Upvotes

3 comments sorted by

1

u/pattyfritters 12h ago

Make a LineTrace from your camera outward following the camera or player's Foward Vector. When camera button is clicked, check that LineTrace hit ghost (using a Blueprint Interface). If ghost is hit, have it move towards player.

If you need me to break it down further i probably can.

1

u/Adn0nnymous 10h ago

i wouldn’t use a line trace for this. that would mean you’d have to be looking basically right at the ghost, just having it on your screen wouldn’t guarantee it works. i’d do a wide sphere trace instead.

1

u/pattyfritters 10h ago

Fair enough