A*Pathfinding Align to Ground

KO_Games

Member
Hi Justin,

I'm using behavior designer with the A* pathfinding movement pack integration. I have an AI character that I'm trying to get to align to the ground when moving up slopes. See image.

1655976992412.png

When I add the align to ground ability to the character that is being controlled with the A* AI Agent Movement ability the character jitters and moves oddly when going up slopes. It seems that the reason for this is because align to ground ability and the A Star AI Agent Movement ability that uses a A* pathfinding script like (AI Path) are fighting with each other.
The AI pathfinding script has a bool option to enable rotation (see image below). If I uncheck the "enable rotation" the character does align to the ground as expected. However, the character now no longer rotates to face the correct direction. It faces the same constant direction (but it will align to the ground).

1655977165168.png

My thought was that perhaps AStarAIAgentMovement ability script needs a way to know if the align with ground ability is active. If so, perhaps it should only update the rotation on the Y axis? That way the AStarAIAgentMovement makes sure the character is facing the correct direction. Then the align with ground ability would rotate the character to align with the ground. Not sure if this is the best approach or if there is another option that is preferred?

Another hack solution might be to inherit the AStarAIAgentMovement script to create a separate ability that only updates the Y rotation? Looking through the AStarAIAgentMovement script I noticed this section regarding the rotation that gets applied. Perhaps there is something that could be written here to do that?

C#:
public override void Update()
        {
            ...

            var rotation = m_NextRotation * Quaternion.Inverse(m_Transform.rotation);
            m_DeltaRotation.y = Utility.MathUtility.ClampInnerAngle(rotation.eulerAngles.y);

            base.Update();
        }   

        /// <summary>
        /// Notify IAStarAI of the final position and rotation after the movement is complete.
        /// </summary>
        public override void LateUpdate()
        {
            m_IAstarAIAgent.FinalizeMovement(m_Transform.position, m_Transform.rotation);
        }

Or perhaps there is somewhere else in code that I should do this? I don't know how to work with Quaternions and Euler angles much, so I'm not really sure how to progress on this any farther at this point. If you are able to help with getting the align with ground ability to work with the AStarAIAgentMovement ability that would be awesome!

Thanks!
 
The A* ability does not support changing the gravity direction so that's the problem that you're having here. I have it on my list of things to look at but haven't had a chance to yet. It will take modification to the Update Rotation method.
 
The A* ability does not support changing the gravity direction so that's the problem that you're having here. I have it on my list of things to look at but haven't had a chance to yet. It will take modification to the Update Rotation method.
Thanks, Justin for the response. I know you are super busy. Is this something that you might have time to look at in the coming weeks? Or is this most likely months out?
 
Top