Agent moving side to side when going up ramp/slope

When an agent goes up a ramp its slowing down and rotating left and right making it look like its squirming to get up the ramp. I thought it was a gravity issue but I disabled gravity and it still does it. What might be causing this?

Also, as a second question. I am wanting to play a sound when an agent is moving but stop the sound when the agent stops moving, I had it working with Unitys built in navmesh system but with A* I changed it to use the agent.velocity but when the agent stops moving the velocity never goes to 0,0,0 there are always values, what do you recommend here? Thank you for your help!

I am also needing to use the velocity to drive a blendtree so still stuck on how to fix the issues with the velocity returning strange values when not moving. cheers.

Hi

  1. Do you think you could post a video of the issue?

  2. What velocities are you getting near the end? Is the character visibly moving?

Sure thing, I was able to fix the weird side to side movement by adding proper physics materials to the agent and surfaces. Here is a video showing how neither the agent velocity or rigidbody velocity zero out when the character stops moving.
https://www.youtube.com/embed/8nYHc_8HKX0

I am also having another issue, the slime in that first video has the speed set to 1, but I actually need the slime to move at 0.1, At this setting it seems like its not getting enough velocity to get up the ramp as seen in this second video. The slime has a very large mass based on real world calculation for its size of 288kg, it is using a max friction physics materials as well, so not sure how to make this work with physics. Thank you so much for your help I am very grateful!
https://www.youtube.com/embed/vu8fQVMk320

I also wanted to ask if I should be using the rigidbody velocity or RichAI velocity for animation movement control? (movement speed?)

Today I am trying to align a walking animation with the agent move speed and am having difficulty. The max speed of the agent is 1.0f but the agent actually gets up to a velocity of 4, I guess I dont understand the relationship between max speed and velocity and still confused on how to sync my animation speed to the agent (which values I should be using). I have tried both with physics and kinematically with the same result. This is the basic movement code I am using:

        //normalizing wasnt working very well when the speed would decrease so I have been trying
        //without normalization.
        //agentVelocity = agent.transform.InverseTransformDirection(agent.velocity).normalized;

        agentVelocity = agent.transform.InverseTransformDirection(agent.velocity);
        agentMoveSpeed = agentVelocity.z;
        agentTurnSpeed = agentVelocity.x;

        animator.SetFloat("MoveSpeed", agentMoveSpeed, moveSpeedDampen, Time.deltaTime);
        animator.SetFloat("TurnSpeed", agentTurnSpeed, turnSpeedDampen, Time.deltaTime);

Regarding the velocities being larger. Have you scaled the whole object possibly?

Yeah the RichAI script does not necessarily reach a (0,0,0) velocity, however comparing to (0,0,0) with floating point values is a pretty bad idea in any case due to floating point errors. I would recommend doing something like ai.velocity.magnitude < 0.01f.

Thank you Aron, can you address this issue as well?

" I am also having another issue, the slime in that first video has the speed set to 1, but I actually need the slime to move at 0.1, At this setting it seems like its not getting enough velocity to get up the ramp as seen in this second video. The slime has a very large mass based on real world calculation for its size of 288kg, it is using a max friction physics materials as well, so not sure how to make this work with physics. Thank you so much for your help I am very grateful!
https://www.youtube.com/embed/vu8fQVMk320 "

I would guess that the physics is pulling it down so much that it counteracts the velocity the movement script is trying to set.

Do you need to use a rigidbody for that agent? Usually for moving agents not using a rigidbody (or at least using a kinematic one) is much easier.

The only reason I switched to using physics is when the slime would go up a ramp it did not rotate at an angle like it adhered to the surface, the slime would just remain at the same angle as it went up the slope, how can I keep it kinematic but get it to align to the surface?

Also you had asked if I was scaling and I was by a factor of x4 (4,4,4). I wanted to have a scaling system for my NPC’s to create variation does it not work correctly with the AI system? or is there something else I need to do if I want scale variations?
Thank you again!

Hi

You an align the object using a script instead. You can use Physics.Raycast downwards and then align the object using the hit normal. I’m sure there are example scripts doing exactly this if you search for it on google.

I’m not sure why the velocity is not correct… You are using InverseTransformDirection properly instead of InverseTransformPoint, so it’s not that…

Okay no worries, i will do some more tinkering, thank for your help!