Vector3.Lerp Equivalent

CuPants

New member
I have been building a multiplayer game that uses Unity's Vector3.Lerp function to interpolate networked character movement when a new position for each character is received. These are just on capsules at the moment so they slide around but it all works smoothly. I have been trying to replace these sliding capsules with the character controllers from the ultimate character controller but can't quite figure out how to mimic this sort of behavior. I'm guessing that the character to create for networked characters should be a third person character with the AI Agent selected? I know I don't want the Ultimate Character Locomotion Handler attached to it since it shouldn't move from user input. I've tried simply calling the Ultimate Character Locomotion SetPosition but obviously that neither interpolates or animates the movement, just jumps the character around on each position update. I've also looked into using the MoveTowards ability but the code and documentation don't allude to that suiting my needs in this situation.

I don't yet have a full understanding of a lot of how these character controller components work so I apologize if I'm using anything incorrectly or missing something simple. My goal right now is to just be able to create a demo character (Nolan for instance) that I can control with a script similar to that which I've pasted below and have been struggling quite a bit as there is a lot to learn with this controller.

For reference, here is lerp controller I currently have attached to networked players. player.Avatar gets set to the player gameobject (the capsule). LastRealPosition and RealPosition get updated accordingly each time a position packet for that character is received. Any help at all would be greatly appreciated!

C#:
public class PlayerLerpController : MonoBehaviour {
    public Player player;

    private void FixedUpdate() {
      NetworkLerp();
    }

    private void NetworkLerp() {
      if (player.IsLerpingPosition) {
        float lerpPercentage = (Time.time - player.TimeStartedLerping) / player.TimeToLerp;

        player.Avatar.transform.position = Vector3.Lerp(player.LastRealPosition, player.RealPosition, lerpPercentage);

        if (lerpPercentage >= 1) {
          player.IsLerpingPosition = false;
        }
      }

      if (player.IsLerpingRotation) {
        float lerpPercentage = (Time.time - player.TimeStartedLerping) / player.TimeToLerp;

        player.Avatar.transform.rotation =
          Quaternion.Lerp(player.LastRealRotation, player.RealRotation, lerpPercentage);
       
        if (lerpPercentage >= 1) {
          player.IsLerpingRotation = false;
        }
      }
    }
  }

Edit: Final clarification, I'm not looking for help with any of the networking as that all works as intended. I guess the best way to describe it is I'm looking for a way to move said character from position 'x' to position 'y' over 't' period of time.
 
The correct way would be to create an ability but for networking you don't want to run the main UltimateCharacterLocomotion.Move loop on the remote players. This will allow you to have a component that syncs the transform and the animations without needing to run the character calculations.
 
Top