【发布时间】:2018-07-07 07:29:13
【问题描述】:
所以我正在创建一个自上而下的射击游戏,并试图让玩家面对操纵杆的方向。这是我当前的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(PlayerMotor))]
public class PlayerController : MonoBehaviour {
Camera cam;
PlayerMotor motor;
void Start () {
cam = Camera.main;
motor = GetComponent<PlayerMotor>();
}
void Update () {
//movement
motor.MoveToPoint(new Vector3(transform.position.x + Input.GetAxis("Horizontal"), transform.position.y, transform.position.z + Input.GetAxis("Vertical")));
//cam control
cam.transform.position = new Vector3(transform.position.x,
transform.position.y + 9.0f,
transform.position.z);
//this is the problem
transform.Rotate(new Vector3(transform.position.x + Input.GetAxis("rightStickHorizontal"), transform.position.y, transform.position.z + Input.GetAxis("rightStickVertical")));
}
}
由于某种原因,当我这样做时,它只会向操纵杆方向缓慢转动(似乎每帧 1 度)。
【问题讨论】: