discofever
New member
So i've been trying to make a new ability where :
1. Player teleports to sit down location
2. Sit down animation plays
3. State 'Sit' enables (limiting view + rotation)
4. When long pressing the Interact button stands up
First time it works just fine; after player stands up but then followin times it exits the state immediately.
Since i want the player to 'Teleport' to location I think i want to use an Interactable where i move the user and thus requiring this 'Interactable' ability first.
Ability code:
Ability Inspector
The Interactable Sofa
Interactable Couch code:
Animator Enter State
Animator Exit State:
1. Player teleports to sit down location
2. Sit down animation plays
3. State 'Sit' enables (limiting view + rotation)
4. When long pressing the Interact button stands up
First time it works just fine; after player stands up but then followin times it exits the state immediately.
Since i want the player to 'Teleport' to location I think i want to use an Interactable where i move the user and thus requiring this 'Interactable' ability first.
Ability code:
C#:
using Opsive.UltimateCharacterController.Character.Abilities;
using UnityEngine;
public class Sit : DetectObjectAbilityBase
{}
Ability Inspector
The Interactable Sofa
Interactable Couch code:
C#:
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities;
using Opsive.UltimateCharacterController.Traits;
using UnityEngine;
public class InteractableCouch : MonoBehaviour, IInteractableTarget, IInteractableMessage
{
[SerializeField] private Transform teleportTarget;
[SerializeField] private bool snapAnimator = true;
[SerializeField] private bool stopAbility = false;
public bool CanInteract(GameObject character, Interact interactAbility)
{
return true;
}
public void Interact(GameObject character, Interact interactAbility)
{
var characterLocomotion = character.GetComponent<UltimateCharacterLocomotion>();
characterLocomotion.SetPositionAndRotation(teleportTarget.position, teleportTarget.rotation, snapAnimator, stopAbility);
var sitAbility = characterLocomotion.GetAbility<Sit>();
if (!characterLocomotion.TryStartAbility(sitAbility)) Debug.Log("Cannot start ability");
}
public string AbilityMessage()
{
return "Sit";
}
}
Animator Enter State
Animator Exit State: