public void DeactivateColliders() { bannedGameObjects.Clear(); components.indexComponent.GetCollider().isTrigger = true; components.thumbComponent.GetCollider().isTrigger = true; components.fistComponent.GetCollider().isTrigger = true; status = HandInteractionStatus.Triggering; if (gameObjectInHand != null) { var rigidBody = gameObjectInHand.GetComponent <Rigidbody>(); if (rigidBody) { rigidBody.isKinematic = false; } rigidBody.velocity = momentum.LinearVelocity; rigidBody.AddForce(momentum.LinearAcceleration, ForceMode.Force); // mass is added automatically ? rigidBody.angularVelocity = momentum.AngularVelocity; var Q = rigidBody.transform.rotation * rigidBody.inertiaTensorRotation; var I = rigidBody.inertiaTensor; var angular_acceleration_body = Quaternion.Inverse(Q) * momentum.AngularAcceleration; var torque = Q * Vector3.Scale(I, angular_acceleration_body); Debug.Log(torque); rigidBody.AddTorque(torque); SetGameObjectInHand(null); } }
public void Initialize( HandComponents handComponents, HandBonesTransformations transformations) { this.transformations = transformations; components = handComponents; status = HandInteractionStatus.None; timeHolding = 0; gameObjectInHand = null; momentum = new HandMomentum { LinearVelocity = new Vector3(), LinearAcceleration = new Vector3(), AngularVelocity = new Vector3(), AngularAcceleration = new Vector3() }; bannedGameObjects = new List <GameObject>(); DeactivateColliders(); }
public void ActivateColliders() { components.indexComponent.GetCollider().isTrigger = false; components.thumbComponent.GetCollider().isTrigger = false; components.fistComponent.GetCollider().isTrigger = false; var fistGameObjectInHand = components.fistComponent.GetGameObjectInHand(); if (fistGameObjectInHand != null && !IsBanned(fistGameObjectInHand)) { SetGameObjectInHand(fistGameObjectInHand); var rigidBody = gameObjectInHand.GetComponent <Rigidbody>(); if (rigidBody) { rigidBody.isKinematic = true; } status = HandInteractionStatus.Holding; } }