improved door grabbing. Sometimes leaves ghost hands.
This commit is contained in:
@@ -10,6 +10,8 @@ namespace _PROJECT.NewHandPresence
|
||||
public bool showController;
|
||||
public bool showHand;
|
||||
|
||||
private bool inDoorGrabRadius = false;
|
||||
|
||||
public InputDeviceCharacteristics controllerCharacteristics;
|
||||
public List<ControllerInformationScriptableObject> controllerInformation;
|
||||
|
||||
@@ -113,5 +115,37 @@ namespace _PROJECT.NewHandPresence
|
||||
updateAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (!inDoorGrabRadius) return;
|
||||
if (_spawnedHandModel != null)
|
||||
_spawnedHandModel.SetActive(false);
|
||||
|
||||
if (_spawnedController != null)
|
||||
_spawnedController.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// Let Update handle visibility naturally
|
||||
// or force refresh:
|
||||
if (_spawnedHandModel != null)
|
||||
_spawnedHandModel.SetActive(showHand);
|
||||
|
||||
if (_spawnedController != null)
|
||||
_spawnedController.SetActive(showController);
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.GetComponent<DoorHandReplacer>() == null) return;
|
||||
inDoorGrabRadius = true;
|
||||
}
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.GetComponent<DoorHandReplacer>() == null) return;
|
||||
inDoorGrabRadius = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user