- Edited
Hello!
In unity i would generally have the following structure for something like interacting with objects.
(Pseudocodish)
public interface IInteractable
{
public void OnInteract();
}
public class SomeClass : Monobehaviour, IInteractable
{
public void OnInteract()
{
//do something
}
}
public class Player : Monobehaviour
{
void Update
{
if( button for interacting was pressed)
Interact();
}
void Interact()
{
Colliders coliders = Physics.OverlapBox(playerposition,facingdirectionofplayer,distance,collisionlayer);
foreach(Collider col in colliders)
{
if(col.Trygetcomponent(out IInteractable interactable))
interactable.OnInteract();
}
}
}`
Something like this is easily applies for all kinds of things like damaging, healing etc.
How would you guys translate this into godot with c#?