嗨我做了一个团结的场景,玩家可以在花园里散步,这项工作很好,但是当我拉动时我需要 在纸板中的磁传感器,玩家走路时不停地直到掉落磁传感器。 我将这个例子用于移动Navigation Plug-in
using UnityEngine;
using System.Collections;
public class PlayerMotor : MonoBehaviour {
public GameObject Cursor; // Google Cardboard SDK: Cursor / GazePointer from CardboardMain Prefab
private Vector3 goal;
private NavMeshAgent agent;
public GameObject miPlayer;
private Vector3 startingPosition;
private Vector3 firstFloorPosition;
private Vector3 secondFloorPosition;
private Vector3 thirdFloorPosition;
void Start() {
this.agent = GetComponent<NavMeshAgent>();
this.goal = new Vector3(0f, 0f, 0f);
startingPosition = miPlayer.transform.localPosition;
}
//Set navigation destination to the position of the cursor
//Ex. Call this from an event trigger on the floor object
public void SetDestinationToCursor() {
this.goal = Cursor.transform.position;
MoveToDestination();
}
////code of move of position of the player(Camara)
public void goToFirstFloor(){
this.goal = firstFloorPosition;
MoveToDestination();
}
public void goToSecondFloor(){
this.goal = firstFloorPosition;
MoveToDestination();
}
public void goToThirdFloor(){
this.goal = thirdFloorPosition;
MoveToDestination();
}
////
public void DisableMeshRendererCursor(GameObject cursor){
cursor.GetComponent <MeshRenderer>().enabled = false;
}
public void EnableMeshRendererCursor(GameObject cursor){
cursor.GetComponent <MeshRenderer>().enabled = true;
}
public void ResetDestinationToCursor() {
this.goal = startingPosition;
MoveToDestination();
}
public void ExitApplication(){
Application.Quit ();
}
void MoveToDestination(){
this.agent.destination = goal;
}
}
我在Unity手册中证明了该示例的其他代码,但没有工作docs.unity3d