- Import Hodaart Low Poly Character Collection 3 (humanoid-rigged, LFS) - PlayerAvatar.cs: owner-authoritative CharacterController movement, animation derived from measured speed on every client (no NetworkAnimator needed) - OwnerAuthNetworkTransform.cs: owner-authoritative NetworkTransform - PlayerLocomotion.controller: Idle/Walk/Run 1D blend tree on Speed (reuses Hodaart clips) - PlayerCharacter.prefab (Character 01 + CC + NetworkObject + owner NT + PlayerAvatar + Animator w/ humanoid avatar); registered as PlayerPrefab - Verified in play: spawns, visible, Idle pose (rig animates), owner-auth Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
namespace LowPolyCharacterCollection3
|
|
{
|
|
public class DragRotateController : MonoBehaviour,
|
|
IPointerDownHandler, IDragHandler, IPointerUpHandler
|
|
{
|
|
[SerializeField] private Transform targetToRotate;
|
|
[SerializeField] private float rotationSpeed = 0.3f;
|
|
[SerializeField] private float smoothSpeed = 10f;
|
|
|
|
private float targetY;
|
|
private float currentY;
|
|
private float lastPointerX;
|
|
private bool isDragging;
|
|
|
|
void Start()
|
|
{
|
|
currentY = targetY = targetToRotate.eulerAngles.y;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
currentY = Mathf.Lerp(currentY, targetY, Time.deltaTime * smoothSpeed);
|
|
targetToRotate.rotation = Quaternion.Euler(0f, currentY, 0f);
|
|
}
|
|
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
isDragging = true;
|
|
lastPointerX = eventData.position.x;
|
|
}
|
|
|
|
public void OnDrag(PointerEventData eventData)
|
|
{
|
|
if (!isDragging) return;
|
|
|
|
float deltaX = eventData.position.x - lastPointerX;
|
|
lastPointerX = eventData.position.x;
|
|
|
|
targetY -= deltaX * rotationSpeed;
|
|
}
|
|
|
|
public void OnPointerUp(PointerEventData eventData)
|
|
{
|
|
isDragging = false;
|
|
}
|
|
}
|
|
}
|