Пример #1
0
        void ProjectGaze()
        {
            Vector3 origin = cameraTransform.position;

            Vector3 direction = cameraTransform.TransformDirection(localGazeDirection);

            if (Physics.SphereCast(origin, sphereCastRadius, direction, out RaycastHit hit, Mathf.Infinity))
            {
                Debug.DrawRay(origin, direction * hit.distance, Color.yellow);
                GameObject      objectHit = hit.transform.gameObject;
                LanternBehavior beh       = objectHit.GetComponent <LanternBehavior>();
                if (beh != null)
                {
                    // Hit a lantern
                    Debug.Log("Heating a lantern...");
                    beh.Heat();
                }
            }
Пример #2
0
        private IEnumerator DoShoot()
        {
            Vector3 lanternDestinationPos;
            float   velocity     = 0.3f;
            float   deceleration = 0.017f;

            float dist_to_send = Random.Range(MIN_DEST_DIST, MIN_DEST_DIST * 5);

            lanternDestinationPos = getControllerPosition() + this.transform.forward * dist_to_send;

            GameObject      lantern  = GameObject.Instantiate <GameObject>(prefabToShoot);
            LanternBehavior behavior = lantern.AddComponent <LanternBehavior>();

            lantern.transform.position = getControllerPosition();

            while (velocity > 0)
            {
                lantern.transform.Translate(velocity * (lanternDestinationPos - lantern.transform.position));
                velocity -= deceleration;
                yield return(null);
            }
        }