Author: James Clarke
Date: 6/22/2023
This week I had a bit of trouble getting the Flashlight to show in front of the player when the player gets close to an object. I did this because with how the flashlight used to work, if it got close to something the light would be inside the object and not show much of anything in certain instances. The issues I had originally was trying to implement the flashlight itself to be in front of of the player without blocking the player's view. Once I figured that out, I ran into an issue with alternating between two modes and having them work together well. Alternating between the modes was definitely the harder part due to all the small logical details that needed to be corrected.
Picture of close up light being used.
A solution for the first issue I had was adding a secondary light onto the player in order to switch to when the player gets close to something. The solution for the second issue includes a raycast onto the camera that detects if the player's view is hitting a nearby object to decide whether to shine the close up light or the far light. I also used an instance of a "Light" from the Light class to alternate between which light was being affected.
Solution which uses raycasting.
Overall result.
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.