using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TankMovement : MonoBehaviour {
public float moveSpeed = 5; //移动速度
public float angularSpeed = 10; //旋转角度
private Rigidbody thisRigidbody; //刚体
void Start()
{
thisRigidbody = this.GetComponent<Rigidbody>();
}
void FixedUpdate()
{
//方向*输入*速度
float v = Input.GetAxis("VerticalPlayer" + number);
thisRigidbody.velocity = transform.forward * v * moveSpeed;
float h = Input.GetAxis("HorizontalPlayer" + number);
thisRigidbody.angularVelocity = transform.up * h * angularSpeed;
}
}
using System.Collections.Generic;
using UnityEngine;
public class TankMovement : MonoBehaviour {
public float moveSpeed = 5; //移动速度
public float angularSpeed = 10; //旋转角度
private Rigidbody thisRigidbody; //刚体
void Start()
{
thisRigidbody = this.GetComponent<Rigidbody>();
}
void FixedUpdate()
{
//方向*输入*速度
float v = Input.GetAxis("VerticalPlayer" + number);
thisRigidbody.velocity = transform.forward * v * moveSpeed;
float h = Input.GetAxis("HorizontalPlayer" + number);
thisRigidbody.angularVelocity = transform.up * h * angularSpeed;
}
}