Skip to content

Commit

Permalink
fix(Examples): prevent spawning multiple arrows when holding bow
Browse files Browse the repository at this point in the history
There was an issue where the arrow spawner would spawn multiple arrows
when holding the bow because the Oculus Avatar will child the bow
object to the model alias and not the actual controller game object.

The ArrowSpawner code would only check the model alias and not the
actual game object. This fix ensures both are checked.
  • Loading branch information
thestonefox committed Jun 14, 2017
1 parent 50585b3 commit c14d36f
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,23 @@ private bool NoArrowNotched(GameObject controller)
{
if (VRTK_DeviceFinder.IsControllerLeftHand(controller))
{
bow = VRTK_DeviceFinder.GetControllerRightHand(true).GetComponentInChildren<BowAim>();
GameObject controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand(true);
bow = controllerRightHand.GetComponentInChildren<BowAim>();
if (bow == null)
{
bow = VRTK_DeviceFinder.GetModelAliasController(controllerRightHand).GetComponentInChildren<BowAim>();
}
}
else if (VRTK_DeviceFinder.IsControllerRightHand(controller))
{
bow = VRTK_DeviceFinder.GetControllerLeftHand(true).GetComponentInChildren<BowAim>();
GameObject controllerLeftHand = VRTK_DeviceFinder.GetControllerLeftHand(true);
bow = controllerLeftHand.GetComponentInChildren<BowAim>();
if (bow == null)
{
bow = VRTK_DeviceFinder.GetModelAliasController(controllerLeftHand).GetComponentInChildren<BowAim>();
}
}

return (bow == null || !bow.HasArrow());
}
}
Expand Down

0 comments on commit c14d36f

Please sign in to comment.