为什么当我移动这个立方体时 z 会改变? [c#][团结]
Why does the z change when I move this cube? [c#][Unity]
我真的是 unity 的新手,所以我想制作一个简单的 2d 项目,您可以在其中移动立方体。所以我制作了一个脚本来移动立方体,但是当我玩游戏时,Z 随 X 一起变化,所以它会从地图上掉下来。
视频:
https://www.youtube.com/watch?v=M9oHSc6dN2A&feature=youtu.be
我正在使用的脚本:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
private Vector2 input;
public float movementSpeed = 50f;
private float horizontal;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
horizontal = Input.GetAxis ("Horizontal");
rigidbody.AddForce ((Vector2.right * movementSpeed) * horizontal);
}
}
我正在使用 unity 4
您的刚体已 Use Gravity
检查。移动它,它应该可以按照您想要的方式运行。 [错误的轴]
编辑:
刚体有约束 属性。在那里冻结 z 位置。
我真的是 unity 的新手,所以我想制作一个简单的 2d 项目,您可以在其中移动立方体。所以我制作了一个脚本来移动立方体,但是当我玩游戏时,Z 随 X 一起变化,所以它会从地图上掉下来。
视频: https://www.youtube.com/watch?v=M9oHSc6dN2A&feature=youtu.be
我正在使用的脚本:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
private Vector2 input;
public float movementSpeed = 50f;
private float horizontal;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
horizontal = Input.GetAxis ("Horizontal");
rigidbody.AddForce ((Vector2.right * movementSpeed) * horizontal);
}
}
我正在使用 unity 4
您的刚体已 Use Gravity
检查。移动它,它应该可以按照您想要的方式运行。 [错误的轴]
编辑:
刚体有约束 属性。在那里冻结 z 位置。