Interactable
Allows interaction between the Player ( Thanks to the InteractManager ) and this object.
Using Interactable.cs, there are different ways you can achieve custom interactions, simple and advanced.
Attach the component to your interactable object:
For simple interactable objects assign the Interactable Component to an object with a box collider, you can subscribe to the OnInteract event to add your custom behaviour.
For advanced interactable objects:
Create a new C# script.
This new C# script must inherit from Interactable.cs
override the base Interact method from Interactable.cs
Ensure the Interactable Layer is assigned to the same object that contains the Collider & Interactable Component ( or script that inherits from it )
For the Interactable.cs:
interactText
interactableEvents
Functions | Interactable.cs
player ( Transform ) | Protected ( only accessible from scripts that inherit from Interactable.cs )
Player that interacts with the Interactable.
Interact(Transform player) -> Virtual Method
Interact with the Interactable object.
player: Transform that interacts with this interactable
Highlight() -> Virtual Method
Triggers when an Interactable is highlighted.
player: Transform that interacts with this interactable
Unhighlight() -> Virtual Method
Triggers when an interactable is no longer highlighted.
player: Transform that interacts with this interactable
IsForbiddenInteraction is only available in >1.3.6
IsForbiddenInteraction(WeaponController weaponController) -> Virtual Method, Returns a Boolean
Returns whether the interaction is valid or not. Returns false by default, meaning that the interaction can be performed.
weaponController: You can use the WeaponController to access specific components or properties to determine if an interaction is valid, in case you need it.
Last updated