c# - 为什么我在 Unity 中的 Player 在我启动 PlayMode 时会摔倒?
问题描述
我在 Unity 中的立方体随机掉落。它位于一个名为“Ground”的立方体上,下面附有一个移动脚本。上面是显示发生了什么的视频,我也会附上一张图片。图片
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 6f;
// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
if (direction.magnitude >= 0.1f)
{
controller.Move(direction * speed * Time.deltaTime);
}
}
}
解决方案
推荐阅读
- sql-server - 根据同一列的先前值更新行。(MSSQL2008)
- javascript - 处理 JavaScript 空字符串连接
- python - 如何在 python 中使用 selenium webdriver 滚动网页以进行抽搐?
- regex - 如何从字符串的开头和结尾删除新行、回车和水平制表符?
- go - Golang 加密/hmac 全局哈希对象
- java - 多线程 Spring 事务
- mysql - 无法插入记录不正确的整数值
- python - 尝试一定次数后锁定的 Python 密码系统
- java - 为什么java中有些关键字以大写字符开头,而有些关键字以小格式字符开头?
- python - Python simplify list items