Interact Ability issue

Nixou

New member
Hello,
I have an issue trying to sit a character on a chair.
I'm working on the 2.3.1 version of Ultimate Character Controller on Unity 2020.3.2f1.

I created an interactable ability to sit on a chair object, activable pressing the F key when the character collides with a box around the chair. The character have 3 animations here: StandToSit, IDLE_Sit and SitToStand (the user make him stand up by pressing F a second time). To know in which state is the character when the F key is pressed, I created a boolean IsSitting, to start the right animation (StandToSit when we press F while IsSitting = False and SitToStand when we press F while IsSitting = True). This boolean start at false and change every time that F is pressed. My problem is that the F key is linked with other interactable abilities, that I use when my character is near other objets, and even if F is pressed for other abilities, the way I created it my boolean IsSitting will change. So sometimes, after using other abilities, when I want to sit, the F key will try to make my character stand up while is already standing.

Please, if you see any solution to this problem, I would be very gratefull.
 
To handle multiple nearby interactables, you could put different types of interactables on different layers, then have each separate Interact ability on the character only detect the relevant layers, using the ability list's top-to-bottom priority order to manage which interacts take priority over the others.
 
Top