If (Physics. Raycast (ray, out hit)) {
If (hit) starts. GameObject. Tag=="Finsih") {
Jiludian=Vector3 (hit) point) x, hit the point. The y + 0.5, hit the point. The z);
Transform. Rotation=Quaternion. Abbreviated as Slerp (transform. Rotation, targetRotation, Time deltaTime * 5.0);
Above is the wrong statement,
using UnityEngine;
using System.Collections;
Public class zhy: MonoBehaviour {
Public GameObject CAM;
Public bool what zj had;
Public Vector3 jiludian;
Void the Start () {
Jiludian=the transform. The position;
What zj had=false;
}
Void the Update () {
{if (Input. GetMouseButtonDown (0))
Ray Ray=Camera. Main. ScreenPointToRay (Input. MousePosition);
RaycastHit hit;
If (Physics. Raycast (ray, out hit)) {
If (hit) starts. GameObject. Tag=="Finsih") {
Jiludian=Vector3 (hit) point) x, hit the point. The y + 0.5, hit the point. The z);
What zj had=true;
}
}
}
If (what zj had==true) {
Vector3 targetRotation=jiludian - transform. The position;
Quaternion ratation=Quaternion. LookRotation (targetRotation);
The transform. The rotation=ratation;
Transform. Rotation=Quaternion. Abbreviated as Slerp (transform. Rotation, targetRotation, Time deltaTime * 5.0);
The transform. Translate (Vector3. Forward * 10 * Time. DeltaTime);
The transform. The position=jiludian;
If ((Vector3. Short (the transform. The position, jiludian) & lt; {
1.0))
The transform. Translate (Vector3. Forward * 0);
What zj had=false;
}
}
}
}
CodePudding user response:
The two Numbers, a decimal point behind the Numbers of the add a fCodePudding user response:
C # float float data, such as: 0.5 - & gt; Written in 0.5 fIn addition jiludian= new Vector3 (hit) point) x, hit the point. The y + 0.5 f, hit the point. The z);
The transform. The rotation=Quaternion. Abbreviated as Slerp (transform) rotation, new Quaternion (targetRotation. X, targetRotation. J y, targetRotation. J z, 0) and Time. The deltaTime * 5.0 f); This is not a Vector3 type, want to pass the Quaternion type, so it depends on what you will, I just write a,