Forum Discussion
ryleysill
9 years agoHonored Guest
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;
}
}
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
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 17 days ago
- 9 years agoAnonymous
- 2 years ago
- 9 months ago