BGP2017 – Interacting with objects
|
In the game there are various objects and tools you need to interact with. The current implementation has been to ray cast towards a direction and interacting with anything which it hits. There was also no visual indication of what you could pick up. This made it very unclear as to when and what they could interact with. To solve this some changes had to be made. Previously checking if there was something to interact with was only done when the player pressed the interact button. However we wanted to show an outline around materials and tools which the player could interact with, so instead the checking of objects you can interact with now happens every frame. The outline is achieved by using a child object with a copy of the mesh and using a material with a shader which renders an outline and scaling the object up slightly. When the material can be interacted with the child object is activated and the outline is rendered. The shader is taken from http://wiki.unity3d.com/index.php/Silhouette-Outlined_Diffuse. In addition to this, we also changed the way we find objects to interact with. From only casting a ray to now casting a sphere around the avatar. This means there is a larger area from which the player can pick up an item. In order to decide what object we will interact with out of the possible ones we can get from the sphere cast, we first make sure the angle between the object and the player is not too large and then the chosen object is the object with the smallest angle. The last change we made was polishing interaction with the crafting table when trying to leave a material on it. To put materials down on the crafting table, whenever the player tries to put down the material a sphere is casted around the player, if it hits an object with a component called SnapPosition, it checks if it can put down the material there. If it can the item is snapped to that object. These changes has made interacting with the materials and tools a whole lot easier and helped iron out some other various bugs. |