Exemplo n.º 1
0
        public bool TrySetThrowableObject(BaseGrabbable grabbable, InteractionSourcePose poseInfo)
        {
            if (grabbable == null)
            {
                return(false);
            }

            if (!grabbable.GetComponent <BaseThrowable>())
            {
                return(false);
            }

            if (!grabbable.GetComponent <Rigidbody>())
            {
                return(false);
            }

            Rigidbody rb = grabbable.GetComponent <Rigidbody>();
            //Debug.Log("name of our rb.center of mass ========= " + rb.name);
            ControllerReleaseData controlReleaseData = grabbable.GetComponent <Rigidbody>().GetThrowReleasedVelocityAndAngularVelocity(rb.centerOfMass, poseInfo);

            //grabbable.GetComponent<BaseThrowable>().LatestControllerThrowVelocity = vel;
            //grabbable.GetComponent<BaseThrowable>().LatestControllerThrowAngularVelocity = vel;

            grabbable.GetComponent <BaseThrowable>().LatestControllerThrowVelocity        = controlReleaseData.Velocity;
            grabbable.GetComponent <BaseThrowable>().LatestControllerThrowAngularVelocity = controlReleaseData.AngleVelocity;
            grabbable.GetComponent <TrailRenderer>().enabled = true;
            return(true);
        }
Exemplo n.º 2
0
        private IEnumerator ThrowDelay(Vector3 vel, Vector3 angVel, BaseGrabbable grabbable)
        {
            yield return(null);

            GetComponent <Rigidbody>().velocity        = vel * ThrowMultiplier;
            GetComponent <Rigidbody>().angularVelocity = angVel;
            if (ZeroGravityThrow)
            {
                grabbable.GetComponent <Rigidbody>().useGravity = false;
            }
        }
Exemplo n.º 3
0
        public override void Throw(BaseGrabbable grabbable)
        {
            base.Throw(grabbable);
            //Vector3 vel = grabbable.GetAverageVelocity();
            Vector3 vel    = LatestControllerThrowVelocity;
            Vector3 angVel = LatestControllerThrowAngularVelocity;

            if (GetComponent <GrabbableFixedJoint>() || GetComponent <GrabbableSpringJoint>())
            {
                StartCoroutine(ThrowDelay(vel, angVel, grabbable));
            }
            else
            {
                GetComponent <Rigidbody>().velocity        = vel * ThrowMultiplier;
                GetComponent <Rigidbody>().angularVelocity = angVel;
                if (ZeroGravityThrow)
                {
                    grabbable.GetComponent <Rigidbody>().useGravity = false;
                }
            }
        }