gpt4 book ai didi

unity mouse rotation lag(单位鼠标旋转延迟)

转载 作者:bug小助手 更新时间:2023-10-25 14:23:29 32 4
gpt4 key购买 nike



I am making a game in unity and the rotation of my character moves to some random location whenever I have a lag spike. I have no clue what could be causing it and I could not find anything else on the internet on this. Here is my code:

我正在制作一个统一的游戏,每当我有一个滞后钉子时,我的角色的旋转就会移动到某个随机的位置。我不知道可能是什么原因造成的,我在互联网上也找不到关于这件事的任何其他信息。以下是我的代码:


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class mouselook : MonoBehaviour
{

[Range(1f,1000f)]
public float mouseSensitivity;

public Transform playerBody;

private float xRoatation = 0f;

// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
xRoatation = 0f;
}

// Update is called once per frame
void FixedUpdate()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

xRoatation -= mouseY;
xRoatation = Mathf.Clamp(xRoatation, -90f, 90f);

transform.localRotation = Quaternion.Euler(xRoatation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);

}
}

Here is a video link of the problem in action:
https://medal.tv/games/horror-waiwai/clips/1toWBrpQGTahtl/d1337ixaUaC0?invite=cr-MSxrZHcsMTk5MzQ1MzI4LA

以下是这个问题的实际行动的视频链接:https://medal.tv/games/horror-waiwai/clips/1toWBrpQGTahtl/d1337ixaUaC0?invite=cr-MSxrZHcsMTk5MzQ1MzI4LA


I tried changing the update method to fixed update and nothing happened

我尝试将更新方法更改为已修复的更新,但什么也没有发生


更多回答
优秀答案推荐
更多回答

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com