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!
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
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
//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 "
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!
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…