Hi there, i was thinking about making Interaction with Object and Player.
I made a State Machine, and when Player enters Object’s collider, collider’s trigger sends it’s own gameobject to Player’s State_Interaction component.
when Player’s State_Interaction catch it’s Interaction animation’s end, it calls received gameobject’s interaction result function through gameobject’s component.
but to make Interactable Objects widely, such as Switch(call it’s animation) and Obstacle(destroy gameobject), I thought I should use inheritance for using just one method.
So I guess, calling inherited component’s overrided function through parent’s component will be perfect for me. is it possible?
Long story short, Such as;
abstract class Object & virtual void Interaction();
class Object_Switch : Object & void Interaction() { return A; } / class Object_Obstacle: Object & void Interaction() { return B; }
when calling each classes Interaction(); function through gameobject.getcomponent().Interaction(); method → can result be different?
I’m sorry for took your time so long & my poor English. thanks!