【发布时间】:2016-03-03 03:02:28
【问题描述】:
我从基础开始,并在 Unity 网站和 youtube 频道上关注 Unity 官方教程。 我想用轴 x,y,z 在平面上滚动一个球但是如下代码我的球只转移到 -y 它不会在舞台上移动它只是沿着 Y 轴 (-42.83892) 掉下来。
这是代码
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
private Rigidbody rb;
public float speed;
void Start() {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate() {
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.1f, moveVertical);
rb.AddForce(movement*speed);
}
}
这是播放器的选项
【问题讨论】:
-
你的飞机有对撞机吗?
-
网格对撞机对吗?我已经添加了
-
请录制行为视频,使用screentogif.codeplex.com,我用过in the past for questions。创建一个 GIF,然后将其上传到 giphy.com 并将其插入到您的问题中。