Reputation: 472
How do I get the location of center dot in Google Cardboard in Unity3D? I'd like to shoot a cannonball at this center dot when a player pushes the button, but I need to find the direction of the vector that represents this dot.
Upvotes: 0
Views: 166
Reputation: 472
The answer was to use Camera.main.transform.forward
// create the bullet object from the bullet prefab
var bullet = (GameObject)Instantiate(bulletPrefab, Camera.main.transform.position - Camera.main.transform.forward, Quaternion.identity);
// make the bullet move away in front of the player
bullet.GetComponent<Rigidbody>().velocity = Camera.main.transform.forward * 4;
Upvotes: 0
Reputation: 10971
I believe you can use ray casting to achieve this, please check these links: https://unity3d.com/learn/tutorials/modules/beginner/physics/raycasting http://docs.unity3d.com/ScriptReference/Physics.Raycast.html
Upvotes: 1