2017-06-22 5 views
1

には移動しない私は、ゲームにGVRカムを移動する必要がありますが、Androidアプリでそれが動かない... :私のプレイヤーが自分のGVRアプリケーション

public class controller : MonoBehaviour { 


private bool walking = false; 
private Vector3 spawnPoint; 

void Start() { 

    spawnPoint = transform.position; 
} 


void Update() { 

    if (walking) 
    { 
     transform.position = transform.position + Camera.main.transform.forward * 3 * Time.deltaTime; 
    } 

    if (transform.position.y <-10f) 
    { 
     transform.position = spawnPoint; 
    } 

    Ray ray = Camera.main.ViewportPointToRay(new Vector3(.5f, .5f, 0)); 
    RaycastHit hit; 

    if (Physics.Raycast (ray, out hit)) 
    { 
     if (hit.collider.name.Contains("plane")) 
     { 
      walking = false; 
     } else 
     { 
      walking = true; 
     } 
    } 

} 

In the image linked here there is my plane

答えて

0

それは、このことがあります。

if (hit.collider.name.Contains("plane")) 

が、現場にあなたは "飛行機" ではない "プレーン" を持っている

;)

名前で確認するのではなく、レイヤーとレイヤーマスクを使用してみます。あなたはこれについてここで読むことができます:Unity Manual: Layers

関連する問題