Hi, I need help with a little problem.
I have several chairs in a room the player can interact with. On all of them is a copy of a sitting.cs script. The player can enter “Sitting mode” and when standing up leave “sitting mode”. In my character controller I call a function when the player presses the key to stand up. However the function is not called on the gameObject the player is sitting on, but allways on the 5th in the hierarchie. I need to call the function only on the gameObject the player is sitting on.
In PlayerController I have:
public void stopSitting()
isSitting = false;
sitting.isInSitMode = false;
In Sitting.cs there is:
public void resetC()
As said, I have a hand full of objects the Sitting.cs is attached to. How would I call the resetC function and set the bool ONLY on the one I’m interacting with. I understand that I need to check what chair I’m sitting on and than call the function only on the script copy that is on the gameObject. How would I do that? List? Would be nice to see a code example.