Setting Rotation Through Ability

dumbgamedev

New member
Hi,

I am trying to set the rotation to match another transform via the ability system. This seems like it should work, but the character actually just moves laterally and then off the screen (no rotation at all).

C#:
using UnityEngine;
using Opsive.UltimateCharacterController.Character.Abilities;

public class Observe: Ability
{

    [SerializeField]
    protected Transform m_MatchRotation;

    public override void UpdateRotation()
    {
        var angles = m_MatchRotation.localRotation;
        var rotation = Quaternion.Euler(new Vector3(m_CharacterLocomotion.DeltaRotation.x, angles.y, m_CharacterLocomotion.DeltaRotation.z));


        m_CharacterLocomotion.SetRotation(rotation);
       
        base.UpdateRotation();
    }
}

This is with no other abilities set. No other input on and third person.
 
Last edited:
SetRotation will teleport the character to the new rotation and during an ability this will make things not work correctly. You should instead set m_CharacterLocomotion.DeltaRotation for the angle difference that you want your character to move.
 
Top