private RayHitComparer rayHitComparer;              // variable to compare raycast hit distances


	void Start() {

        // find the camera in the object hierarchy
		cam = GetComponentInChildren<Camera>().transform;
		pivot = cam.parent;
		originalDist = cam.localPosition.magnitude;
		currentDist = originalDist;

        // create a new RayHitComparer
        rayHitComparer = new RayHitComparer();
	}
        private RayHitComparer m_RayHitComparer;  // variable to compare raycast hit distances


        private void Start()
        {
            // find the camera in the object hierarchy
            m_Cam = GetComponentInChildren<Camera>().transform;
            m_Pivot = m_Cam.parent;
            m_OriginalDist = m_Cam.localPosition.magnitude;
            m_CurrentDist = m_OriginalDist;

            // create a new RayHitComparer
            m_RayHitComparer = new RayHitComparer();
        }
    private RayHitComparer m_RayHitComparer;  // variable to compare raycast hit distances


    private void Start()
    {
        // find the camera in the object hierarchy
        m_Cam          = GetComponentInChildren <Camera>().transform;
        m_Pivot        = m_Cam.parent;
        m_OriginalDist = m_Cam.localPosition.magnitude;
        m_CurrentDist  = m_OriginalDist;

        // create a new RayHitComparer
        m_RayHitComparer = new RayHitComparer();
    }
Ejemplo n.º 4
0
        private RayHitComparer rayHitComparer; // variable to compare raycast hit distances


        public void Start()
        {
            // find the camera in the object hierarchy
            cam          = GetComponentInChildren <Camera>().transform;
            pivot        = cam.parent;
            originalDist = cam.localPosition.magnitude;
            currentDist  = originalDist;

            // create a new RayHitComparer
            rayHitComparer = new RayHitComparer();
        }
Ejemplo n.º 5
0
	// Use this for initialization
	void Start () {
		// Find the camera in the object hierarchy
		m_Camera = GetComponentInChildren<Camera>().transform;

		// Find the pivot in the object hierarchy, should ALWAYS be the parent to the camera
		m_Pivot = m_Camera.parent;

		m_OriginalDistance = m_Camera.localPosition.magnitude;
		m_CurrentDistance = m_OriginalDistance;

		m_RayHitComparer = new RayHitComparer();
	}
Ejemplo n.º 6
0
        private RayHitComparer m_RayHitComparer;        // variable to compare raycast hit distances



        private void Start()
        {
            var MFreeLookCamera = GetComponent <MFreeLookCamera>();

            m_Cam          = MFreeLookCamera.CamT; //find the camera in the object hierarchy
            m_Pivot        = MFreeLookCamera.Pivot;
            m_OriginalDist = m_Cam.localPosition.magnitude;
            m_CurrentDist  = m_OriginalDist;

            m_RayHitComparer = new RayHitComparer();         // create a new RayHitComparer

            MFreeLookCamera.OnStateChange.AddListener(SetOriginalDist);
        }
Ejemplo n.º 7
0
    private void Start()
    {
        // Camera rotation
        Vector3 rot = transform.localRotation.eulerAngles;

        rotation.x = rot.x;
        rotation.y = rot.y;

        // Ray Hits comparer
        rayHitComparer = new RayHitComparer();

        GetComponent <Camera>().transform.position = offset;
    }
Ejemplo n.º 8
0
        private RayHitComparer m_RayHitComparer;  // variable to compare raycast hit distances


        private void Start()
        {
            // find the camera in the object hierarchy
          ///  m_Cam = GetComponentInChildren<Camera>().transform;
            m_Cam = this.transform;
            m_Pivot = m_Cam.parent;
            m_OriginalDist = m_Cam.localPosition.magnitude;
            m_CurrentDist = m_OriginalDist;

            // create a new RayHitComparer
            m_RayHitComparer = new RayHitComparer();
            protectMask = ~LayerMask.GetMask("BossLimit", "Weapon");

        }
Ejemplo n.º 9
0
    private RayHitComparer m_RayHitComparer;       // variable to compare raycast hit distances



    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = true;

        // find the camera in the object hierarchy
        //m_Cam = GetComponentInChildren<Camera>().transform;
        //m_Pivot = m_Cam.parent;
        m_OriginalDist = m_Cam.localPosition.magnitude;
        m_CurrentDist  = m_OriginalDist;

        // create a new RayHitComparer
        m_RayHitComparer = new RayHitComparer();
    }
        private RayHitComparer m_RayHitComparer;  // variable to compare raycast hit distances


        private void Awake()
        {
            // find the camera in the object hierarchy
            m_Cam            = GetComponentInChildren <Camera>().transform;
            m_Pivot          = m_Cam.parent;
            m_OriginalDist   = m_Cam.localPosition.magnitude;
            m_OriginalHeight = 1;
            m_OriginalRotate = 11;
            m_CurrentDist    = m_OriginalDist;

            // create a new RayHitComparer
            m_RayHitComparer = new RayHitComparer();
            CanClip          = true;
        }
        private RayHitComparer m_RayHitComparer;  // variable to compare raycast hit distances


        private void Start()
        {
            // find the camera in the object hierarchy
            m_Cam = GetComponentInChildren <Camera>().transform;
            //Debug.Log(m_Cam.parent.name);
            m_Pivot = m_Cam.parent;         //set m_Pivot to parent transform
            //Debug.Log("m_Cam pos: " + m_Cam.localPosition);
            //Debug.Log("m_Pivot pos: " + m_Pivot.position);
            //m_Pivot.position = m_Cam.localPosition;
            m_OriginalDist = m_Cam.localPosition.magnitude;
            m_CurrentDist  = m_OriginalDist;

            // create a new RayHitComparer
            m_RayHitComparer = new RayHitComparer();
        }
        private RayHitComparer rayHitComparer;                  // variable to compare raycast hit distances


        private void Start()
        {
            // find the camera in the object hierarchy
            cam   = GetComponentInChildren <Camera> ().transform;
            pivot = cam.parent;

            originalCamTrailDistance = cam.localPosition.magnitude;
            originalPivotHeight      = pivot.localPosition.y;

            currentCamTrailDistance = originalCamTrailDistance;
            currentPivotHeight      = originalPivotHeight;

            // create a new RayHitComparer
            rayHitComparer = new RayHitComparer();
        }
Ejemplo n.º 13
0
    public void Move(Vector3 move, bool crouch, bool jump, Vector3 lookPos)
    {
        if (move.magnitude > 1)
        {
            move.Normalize();
        }

        isMovingToTarget = true;

        // grab current velocity, we will be changing it.
        Vector3 velocity = rigidbody.velocity;

        Vector3 localMove     = transform.InverseTransformDirection(move);
        float   turnAmount    = Mathf.Atan2(localMove.x, localMove.z);
        float   forwardAmount = localMove.z;

        float turnSpeed = Mathf.Lerp(180, 360, forwardAmount);

        transform.Rotate(0, turnAmount * turnSpeed * Time.deltaTime, 0);

        Ray ray = new Ray(transform.position + Vector3.up * .1f, -Vector3.up);

        RaycastHit[]   hits           = Physics.RaycastAll(ray, .5f);
        RayHitComparer rayHitComparer = new RayHitComparer();

        System.Array.Sort(hits, rayHitComparer);

        if (velocity.y < 2 * .5f)
        {
            ;
            rigidbody.useGravity = true;
            foreach (var hit in hits)
            {
                // check whether we hit a non-trigger collider (and not the character itself)
                if (!hit.collider.isTrigger)
                {
                    // this counts as being on ground.

                    // stick to surface - helps character stick to ground - specially when running down slopes
                    if (velocity.y <= 0)
                    {
                        rigidbody.position = Vector3.MoveTowards(rigidbody.position, hit.point, Time.deltaTime * 5.0f);
                    }

                    rigidbody.useGravity = false;
                    break;
                }
            }
        }

        velocity.y = 0;

        if (move.magnitude == 0)
        {
            // when not moving this prevents sliding on slopes:
            velocity.x = 0;
            velocity.z = 0;
        }

        // reassign velocity, since it will have been modified by the above functions.
        rigidbody.velocity = velocity;
    }
        // Inicjalizacja zmiennych składowych,
        // nic więcej
        private void Start()
        {
            m_Cam = GetComponentInChildren<Camera>().transform;
            m_Pivot = m_Cam.parent;
            m_OriginalDist = m_Cam.localPosition.magnitude;
            m_CurrentDist = m_OriginalDist;							// Na starcie odległość aktualna jest równa wyjściowej. Poprostu sytuacja początkowa

            m_RayHitComparer = new RayHitComparer();
        }