【发布时间】:2021-08-09 04:57:32
【问题描述】:
我的角色移动得很好。但它没有翻转。我的脚本有什么问题吗? 这是我第一次开发用于练习的演示游戏,如果有人帮助我,我会很高兴。
public class movement2 : MonoBehaviour
{
public float speed = 100;
void Start()
{
}
void Update()
{
var inputX = Input.GetAxis("Horizontal");
Vector3 movement = new Vector3(inputX, 0, 0)*speed;
movement *= Time.deltaTime;
transform.Translate(movement);
Vector2 CharacterScale = transform.localScale;
if (inputX < 0)
{
CharacterScale.x = -1;
}
if (inputX > 0)
{
CharacterScale.x = 1;
}
}
}
【问题讨论】:
标签: c# visual-studio unity3d