Browse Source

updated local pplayer animation calc

master
Joshua Reason 5 years ago
parent
commit
82937f97b8
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      Assets/Scipts/PlayerControllers/RemotePlayer.cs

+ 9
- 2
Assets/Scipts/PlayerControllers/RemotePlayer.cs View File

@ -10,6 +10,8 @@ public class RemotePlayer : Player {
private float walkSpeed; private float walkSpeed;
private Vector3 lastPosition; private Vector3 lastPosition;
private float LastSpeed = 0;
public void Start() public void Start()
{ {
lastPosition = transform.position; lastPosition = transform.position;
@ -26,8 +28,13 @@ public class RemotePlayer : Player {
{ {
Vector3 dir = transform.position - lastPosition; Vector3 dir = transform.position - lastPosition;
lastPosition = transform.position; lastPosition = transform.position;
Animator.SetFloat("WalkSpeed", dir.magnitude);
Debug.Log(dir.normalized);
float DesiredSpeed = dir.magnitude * 10;
float setSpeed = Mathf.Lerp(LastSpeed, DesiredSpeed, 0.1f);
Animator.SetFloat("WalkSpeed", setSpeed);
Debug.Log(setSpeed);
LastSpeed = setSpeed;
PlayerModel.transform.LookAt(PlayerModel.transform.position + dir, Vector3.up); PlayerModel.transform.LookAt(PlayerModel.transform.position + dir, Vector3.up);
//PlayerModel.transform.forward = dir.normalized; //PlayerModel.transform.forward = dir.normalized;

Loading…
Cancel
Save