Saturday 6 December 2014

Winter Project - Raycasting

I decided to apply the use of raycasts in my project. Raycasts in the way I wish to use it means objects can be interacted with or have the ability to interact with by the player just facing the camera towards it. For example the player could just point the camera at the lantern on the table and it would highlight and display a message that it can be interacted with.

I got it working through a lot of experimentation and the creation of a test level. However my first real setup within the game had two raycasts working from the same point. One that highlighted the object and one that would allow the pickup. This seemed bad for a few reasons. Firstly they both came from the same point and this sort of felt buggy because only one ray seemed to respond at any time. And secondly it made the code messy as two code scripts were basically doing the same job.

To fix this I basically just tapped further into the code and created static bools so the scripts could interact with each other, this was a modified version of code I had created for the cabinet triggers. This worked particularly well and has given me a way too clean up code. And have highlight triggers kept to each object and actually interaction triggers assigned to each object as well.


No comments:

Post a Comment