Hello,
I'm making my own animation controller since I use Spine with various skeletons so I'm having trouble with characters velocity.
The accessible properties of the Char class itself don't give the actual velocity, I've debuged the "GetMoveSpeed()" Function itself and it gives confusing values that go from -0.1 to infinity.
How could I get the real velocity in Unity units that my character is moving at the time?
Thanks in advance.
Comments
I'll give it a try and post the results, I hope it doesn't become too resource hungry for my proyect
What does the "GetMoveSpeed()" function return then? I'm confused by it's tendency to reach infinity
Unfortunately I can't calculate the Velocity myself since I need to know the Velocity the character will move while walking and since the characters position is the same as idle when it starts walking the velocity will always be 0.
How do you calculate the velocity the character needs to move depending on where it is?
I could take that as my velocity parameter.
Thank you so much.
The anim engine is custom,
Debug log of the "GetMoveSpeed()" function isn't reaching infinity anymore.
Would it be possible to parse the moveSpeed to Unity units?
Are you using the latest release? Also, what is your Destination accuracy slider value set to in the Settings Manager?
Destination accuracy value is 1 (max).
I can't post the full inspector at the moment since I won't be able to check our project until this friday.
Thanks for your patience and help.
Pathfinding update time is set to 0.
With the latest release, there is actually a new "Retro-mode" movement option in character components which provides pixel-perfect movement without the need for "super-accurate" mode. You may find that it is useful for your needs, so I'd recommend trying it out if you haven't already. More on this option can be found in the "Retro movement" chapter of the Manual.
Otherwise, the literal per-frame speed should be equal to the "newVel" float that's updated in Char.cs' MoveUpdate method. Find the line:
transform.position += (newVel * _deltaTime);
and place in a Debug.Log:
if (this is Player) Debug.Log ("Frame speed: " + newVel);
Does that give more accurate values?
I can't test the "Retro-mode" since we are maintaining the AC version but the "newVel" Variable gives a big value, but it needed to be multiplied by Time.deltaTime.
Problem solved, thanks for your patience.
Have a good day