Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How to map a real person movement with Avatar smoothly

Discussion in 'Animation' started by shibi2017, Apr 18, 2022.

  1. shibi2017


    Jan 18, 2018
    Hi there, I want to using a phone binded on person to detect positions of person in realtime, and pass this position to unity, every frame I caulate the velocity from this frame to last frame and using this value as "play speed" of my movement animation.
    But I found sometimes the avatar in unity play animtion un-continously. It seems the last frame it plays the animation on frame 10th and next frame it goes frame of animation in 15th(or any frame but not continously).
    On speed I do a very simple remap like:

    deltaPosition = now_Position - last_Positon;
    deltaVelocity = deltaPosition / timeOfFrame;
    animator.speed = deltaVelocity;

    I know the position passed by phone got lots of shaking and far away from a nice and smooth movement curve, but at same time I need it react as fast as the person moves. So what kind of ways can I using in this case to animate the avatar better?
  2. Flylake


    Feb 26, 2014
    what does timeOfFrame constitute? Time between two updates (sorta like a delta time)?

    Sounds to me like the Animator speed is being pushed to extreme levels, which might make it skip a few frames to keep up...

    Maybe clamp the animator speed to some max value, Sure you might reach a point where the animation doesn´t move fast enough to look proper for the distance covered in the application, but at least it won't skip any frames

    Another solution might be to increase the number of frames in the animation (if you have access to the animation file) but you might eventually hit the "roof" anyway and you´re back at square one

    A slightly more difficult solution would be to build a system that evaluates all the new movement updates and cull the ones that have a low 'quality' value, based on previous positions and average velocities etc... etc...
    This is quite a common problem in Netcode, and there are tons of information on interpolating positions of networked avatars that could be applicable to this problem as well