By Reign
on Thu, 03/17/2016 - 18:53
I use the following script and attach it to ARCamera. If I fire the projectile facing south, then turn 180 degress facing north, the projectile follows the center of the camera and continues it's path north... Any ideas?
GameObject prefab; Rigidbody rb; // Use this for initialization void Start () { prefab = Resources.Load ("projectile") as GameObject; } // Update is called once per frame void Update () { if (Input.GetMouseButtonDown (0)) { GameObject projectile = Instantiate (prefab) as GameObject; projectile.transform.position = transform.position + Camera.main.transform.forward * 2; rb = projectile.GetComponent<Rigidbody> (); rb.velocity = Camera.main.transform.forward * 40; } }
Another issue I am seeing is the partical effects that trail off the projectile are following the physics of the camera, not the projectile. So if I shoot straight, without gravity, and shake the camera, the partical effects reflect the camera movement...