Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
ryleysill's avatar
ryleysill
Honored Guest
9 years ago

Cannot access the proper rotation of an object if it is childed to the VR camera.

I'm working on a demo where a crossbow is childed to the VR camera in my scene.  The crossbow itself works perfectly. As the player looks around the scene, the crossbow stays in the bottom right hand corner of the player's view.  However, when I instantiate an arrow ( at the position and forward rotation of my crossbow) when my player shoots, the arrow fires from the position of the camera but does not get its current rotation. Everything on the crossbow works fine when I am using a standard camera.  Is there any reason why I can't seem to access the rotation of my crossbow if it is childed to the VR camera?

here is my code:









    void Update(){

        //Shoot

        Vector3 arrowPlacementPosition = arrowPlacement.position;

        Quaternion arrowPlacementRotation = Quaternion.LookRotation (arrowPlacement.forward);



        if (Input.GetButtonDown ("Fire1") && anim.GetCurrentAnimatorStateInfo(0).IsName("Idle")) {

            anim.SetTrigger ("ShootArrow");

                Instantiate(arrowPrefab, arrowPlacementPosition, arrowPlacementRotation);

            triggerHeld = true;

        } else {

            triggerHeld = false;

        }

    }




No RepliesBe the first to reply