-
Notifications
You must be signed in to change notification settings - Fork 0
Interaction
The interaction with game object is implemented via the interactable class and the focus function from the character controller. The focus functions detects what object a player is looking at. If the object is interactalbe it tells the object that it is focused. Afterwards the object checks if the player is in the radius of the object. If so it calls the Interact() functions. This function is virtual and so is overwriten by child classes.
The interactable class should be used to inherite from. Overwrite the interact and StopInteract function.
Give every item that should be interactable a collider. Then you can use the IsTriggered function from unity to detect if the player is inside the interaction collider. Combine this with the focus functionality and check if the object is focused inside the IsTriggered function.
This dosn't need the update function and also brings a very well functioning LeaveTrigger funciton (idk if this method is called like this).