坦克世界腳本按鍵腳本
❶ 為什麼近幾坦克世界天盒子不能用
能用啊,我剛才還玩的。你把你的坦克世界盒子全卸載,然後把整個文件夾刪除,再重新下載盒子安裝試試,我估計是你的插件出了問題,用了限時插件或者新插件,單純在盒子里卸載插件不行,弄不幹凈,必須把文件夾全部刪除後重裝。
❷ unity 3d怎麼才能讓坦克炮塔像坦克世界裡一樣滑鼠移到一定位置然後炮塔慢慢跟上來的那種 有c#源碼最好
把下面的腳本掛載到要轉的物體上
using UnityEngine;
using System.Collections;
public class RobotTurret : MonoBehaviour {
[SerializeField]
private float RotateSpeed = 720f;
[SerializeField]
[Range(0f, 180f)]
private float Limit = 180f;
private float InitLocalRotY = 0f;
void Start () {
InitLocalRotY = transform.localRotation.eulerAngles.y % 360f;
}
void Update () {
Vector3 MouseWorldPosition = Vector3.zero;
Plane plane = new Plane(Vector3.up, transform.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float distance;
if (plane.Raycast(ray, out distance)) {
MouseWorldPosition = ray.origin + ray.direction * distance;
}
Vector3 pos = MouseWorldPosition;
pos.y = transform.position.y;
Quaternion aimRot = Quaternion.RotateTowards(
transform.rotation,
Quaternion.LookRotation(
pos - transform.position,
Vector3.up
),
Time.deltaTime * RotateSpeed
);
transform.rotation = aimRot;
// Clamp
float localY = Mathf.Repeat(transform.localRotation.eulerAngles.y + 180f, 360f) - 180f;
if (Mathf.Abs(Mathf.Abs(localY % 360f) - Mathf.Abs(InitLocalRotY)) > Limit) {
transform.localRotation = Quaternion.Euler(0f, InitLocalRotY + (localY > 0f ? Limit : -Limit), 0f);
}
}
}