Do I use states or abilities and how to I Implement them.

aphixe

New member
I want to make it so player jumps in air towards the direction player wants to go. or say what would I do if I wanted to do a dash in direction, like dodging. would it be a state or an ability. Trying to find the right things to learn in documentation to implement this ideas and more. like items that do certain things.

just thought of how to clear up the action I am trying to get is like diving forward, and in every 4 directions. (forward, backward, left/right side)
 
Last edited:
This would be an ability. As a general rule states can change the values of a piece of functionality, but it cannot add new functionality. In this case the jump ability does not have a feature to move towards a target so it requires a new ability. If you have the agility pack I recommend taking a look at the dash ability for an example implementation (this dash is on the ground instead of the air).
 
I don't have the agility pack. What would the process look like for adding an ability. this is all i see on setup. it looks like a general overview.

is there more details like what using libraries to add and what api calls i need to do. i was able to understand like how the interaction system and i wrote my own code for a button press.

maybe there is documentation i haven't read that i must be not looking at. or example code. maybe there is one already in demo scene

so I looked around and i see this video, and source. I guess this is the example given.
 
Last edited:
this is me trying to figure this out, but sadly it doesn't work. I didn't know best way to handle the input. I set it to Dive in input's under letter H. if I press H it quickly says active in inspector.

Looks like I may have fixed something on how to do it.

Remove this. m_Rigidbody.AddForce(impulseDirection, ForceMode.Impulse);
replace with m_CharacterLocomotion.AddForce(impulseDirection, 1, true);

Code:
using UnityEngine;
using Opsive.UltimateCharacterController.Character.Abilities;


[DefaultAbilityIndex(1313)]
[DefaultStartType(AbilityStartType.ButtonDown)]
/// <summary>
/// Places the character in a diving state.
/// </summary>
public class divejump : Ability
{
    [Tooltip("Jump speed")]
    [SerializeField] protected float jumpSpeed = 10f; // Adjust speed as needed
    [Tooltip("Forward dive speed")]
    [SerializeField] protected float diveSpeed = 5f; // Adjust speed as needed

    private bool m_DiveJumping;
    public float diveDuration = 0.5f; // Duration of the dive forward
    public float jumpHeight = 2f; // Height of the jump

    private bool diving;
    private float diveStartTime;
    //private new Rigidbody m_Rigidbody;

    public override void Awake()
    {
        base.Awake()l
     
    }

   public override bool CanStartAbility()
    {
        return true;
    }

    protected override void AbilityStarted()
    {
        base.AbilityStarted();
        m_DiveJumping = true;
    }

    public override void Update()
    {
        base.Update();

        if (m_DiveJumping)
          if (m_DiveJumping && !diving)
        {
            diving = true;
            diveStartTime = Time.time;

            // Calculate impulse direction
            Vector3 impulseDirection = m_Transform.forward * diveSpeed + Vector3.up * jumpSpeed;
            m_Rigidbody.AddForce(impulseDirection, ForceMode.Impulse);
        }

    }
}
 
Last edited:
Top