Example #1
0
	void Reset() {
        bodyMovements = (IVR_BodyMovements)target;
		InstantVR ivr = bodyMovements.GetComponent<InstantVR>();

		if (ivr == null) {
			Debug.LogWarning("Body Movements script requires Instant VR script on the game object");
			DestroyImmediate(bodyMovements);
			return;
		}

        IVR_BodyMovements[] bodyMovementsScripts = bodyMovements.GetComponents<IVR_BodyMovements>();
		if (bodyMovementsScripts.Length > 1) {
			Debug.LogError("You cant have more than one BodyMovements script");
			DestroyImmediate(bodyMovements); // why does it delete the first script, while target should be the new script...
			return;
		}

		Animator animator = bodyMovements.transform.GetComponentInChildren<Animator>();
		if (animator) {
			avatarGameObject = animator.gameObject;

			prefabPose = false;
			bodyMovements.StartMovements();
		}
	}
Example #2
0
    public void Initialize(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements) {
        this.ivr = ivr;

        this.bodySide = bodySide;
        animator = ivr.GetComponentInChildren<Animator>();

        if (bodySide == BodySide.Left) {
            upperArm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.LeftHand);
        } else {
            upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.RightHand);
        }

        upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
        forearmLength = Vector3.Distance(forearm.position, hand.position);
        length = upperArmLength + forearmLength;
        if (length == 0)
            Debug.LogError("Avatar arm positions are incorrect. Please restore avatar in T-pose.");

        upperArmLength2 = upperArmLength * upperArmLength;
        forearmLength2 = forearmLength * forearmLength;

        upperArmStartPosition = upperArm.position;
    }
Example #3
0
 public ArmMovements(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements) {
     Initialize(ivr, bodySide, bodyMovements);
 }