【发布时间】:2022-01-23 03:55:57
【问题描述】:
所以我制作了一个脚本,理论上应该让角色控制器的碰撞器跟随玩家相机。这是脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class CCCameraFollower : MonoBehaviour
{
public GameObject Camera;
public CharacterController character;
// Start is called before the first frame update
void Start()
{
character = GetComponent<CharacterController>();
}
// Update is called once per frame
void LateUpdate()
{
character.center = Camera.transform.position;
}
}
当我尝试它时,这很好/可以,但是一旦我在我的 Climber 脚本中输入Climb():
void Climb()
{
InputDevices.GetDeviceAtXRNode(climbingHand.controllerNode)
.TryGetFeatureValue(CommonUsages.deviceVelocity, out Vector3 velocity);
character.Move(transform.rotation * -velocity * Time.fixedDeltaTime);
cachedVelocity = -velocity;
Debug.Log(cachedVelocity);
}
当这是 Climb() 运行时,会发生这种情况:
Image that Shows The Issue
我看不出发生这种情况的原因,也许它非常明显。我不知道......无论如何,我的问题是:“我如何让 CC 的 Collider 跟随玩家相机?”。
【问题讨论】:
标签: c# unity3d virtual-reality