ClientServer/Client/Assets/DarkRift/3 BlockDemo/BlockNetworkCharacter.cs
TG9six 03a642d635 first push
first push
2025-09-06 17:17:39 +04:00

51 lines
1.5 KiB
C#

using UnityEngine;
/// <summary>
/// Manages the movement of another player's character.
/// </summary>
internal class BlockNetworkCharacter : MonoBehaviour
{
/// <summary>
/// The speed to lerp the player's position.
/// </summary>
[SerializeField]
[Tooltip("The speed to lerp the player's position")]
public float moveLerpSpeed = 10f;
/// <summary>
/// The speed to lerp the player's rotation.
/// </summary>
[SerializeField]
[Tooltip("The speed to lerp the player's rotation")]
public float rotateLerpSpeed = 50f;
/// <summary>
/// The position to lerp to.
/// </summary>
public Vector3 NewPosition { get; set; }
/// <summary>
/// The rotation to lerp to.
/// </summary>
public Vector3 NewRotation { get; set; }
void Awake()
{
//Set initial values
NewPosition = transform.position;
NewRotation = transform.eulerAngles;
}
void Update()
{
//Move and rotate to new values
transform.position = Vector3.Lerp(transform.position, NewPosition, Time.deltaTime * moveLerpSpeed);
transform.eulerAngles = new Vector3(
Mathf.LerpAngle(transform.eulerAngles.x, NewRotation.x, Time.deltaTime * rotateLerpSpeed),
Mathf.LerpAngle(transform.eulerAngles.y, NewRotation.y, Time.deltaTime * rotateLerpSpeed),
Mathf.LerpAngle(transform.eulerAngles.z, NewRotation.z, Time.deltaTime * rotateLerpSpeed)
);
}
}