Ejemplo n.º 1
0
        private void Update()
        {
            //  m_CameraRefocus.GetFocusPoint();
            Vector3 newCameraPosition;

            if (rigidbodyFirstPersonController.GetComponent <Rigidbody>().velocity.magnitude > 0 && rigidbodyFirstPersonController.Grounded())
            {
                Camera.transform.localPosition = motionBob.DoHeadBob(rigidbodyFirstPersonController.GetComponent <Rigidbody>().velocity.magnitude); // *(rigidbodyFirstPersonController.Running ? RunningStrideLengthen : 1f));
                newCameraPosition    = Camera.transform.localPosition;
                newCameraPosition.y  = Camera.transform.localPosition.y - jumpAndLandingBob.Offset();
                newCameraPosition.z += .33f;
            }
            else
            {
                newCameraPosition   = Camera.transform.localPosition;
                newCameraPosition.y = m_OriginalCameraPosition.y - jumpAndLandingBob.Offset();
            }
            Camera.transform.localPosition = newCameraPosition;

            if (!m_PreviouslyGrounded && rigidbodyFirstPersonController.Grounded())
            {
                StartCoroutine(jumpAndLandingBob.DoBobCycle());
            }

            m_PreviouslyGrounded = rigidbodyFirstPersonController.Grounded();
            //  m_CameraRefocus.SetFocusPoint();
        }
Ejemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
			player = gameObject;
			drone = GameObject.FindGameObjectWithTag("Drone");

			cam = GetComponentInChildren<Camera>();
			DroneCAM = drone.GetComponentInChildren<Camera>();
            mainCharacter = GetComponent<ThirdPersonCharacter>();
			playerControl = mainCharacter.GetComponent<Player>();
			screenFocus = mainCharacter.GetComponent<ScreenFocus>();

			DroneCAM.enabled = false;
		}
Ejemplo n.º 3
0
        // Fixed update is called in sync with physics
        private void FixedUpdate()
        {
            // read inputs
            float h = CrossPlatformInputManager.GetAxis("Horizontal");
            float v = CrossPlatformInputManager.GetAxis("Vertical");

            m_Crouch = Input.GetKey(KeyCode.C);

            // calculate move direction to pass to character
            if (m_Cam != null)
            {
                // calculate camera relative direction to move:
                m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
                m_Move       = v * m_CamForward + h * m_Cam.right;
            }
            else
            {
                // we use world-relative directions in the case of no main camera
                m_Move = v * Vector3.forward + h * Vector3.right;
            }
#if !MOBILE_INPUT
            // walk speed multiplier
            if (Input.GetKey(KeyCode.LeftShift))
            {
                m_Move *= 0.5f;
            }
#endif

            // pass all parameters to the character control script
            m_Character.Move(m_Move, m_Crouch, m_Jump);
            m_Jump = false;

            m_Character.GetComponent <Animator>().Update(Time.deltaTime);
            Physics.Simulate(Time.fixedDeltaTime);
        }
Ejemplo n.º 4
0
        public Transform target;                                // target to aim for


        private void Start()
        {
            // get the components on the object we need ( should not be null due to require component so no need to check )
            agent     = GetComponentInChildren <UnityEngine.AI.NavMeshAgent>();
            character = GetComponent <ThirdPersonCharacter>();
            transform = character.GetComponent <Transform>();

            agent.updateRotation = false;
            agent.updatePosition = true;
        }
Ejemplo n.º 5
0
        private void Start()
        {
            character = GetComponent <ThirdPersonCharacter>();

            carParent = GameObject.Find("Car");

            car = carParent.GetComponent <CarController>();


            speedUpdateFrequency = 200;
            parkUpdateFrequency  = 50;

            rBody           = character.GetComponent <Rigidbody>();
            counter         = (int)UnityEngine.Random.Range(0.0f, parkUpdateFrequency);
            previousTerrain = "";
            movement        = Vector3.zero;
            doStart         = -1;
            makeNeg         = 1.0f;
            finishedStaring = false;
            goingToPark     = false;
            crossingRoad    = false;

            sidewalkSpeed   = UnityEngine.Random.RandomRange(0.1f, 0.8f);
            increasingSpeed = (UnityEngine.Random.RandomRange(0.0f, 1.0f) < 0.5f);

            float typeNum = UnityEngine.Random.Range(0.0f, 1.0f);

            if (typeNum < 0.5f)
            {
                type = 0;
            }
            else
            {
                type        = 1;
                destination = randomParkDestination();
            }
        }
Ejemplo n.º 6
0
 public void Init()
 {
     victim = thirdPersonMovement.GetComponent <Mortal>();
 }
Ejemplo n.º 7
0
        void Awake()
        {
            mainPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent<ThirdPersonCharacter>();
			playerControl = mainPlayer.GetComponent<Player>();
            Drone = GetComponent<GameObject>();
        }
Ejemplo n.º 8
0
 public void CrossDoor(UnityStandardAssets.Characters.ThirdPerson.ThirdPersonCharacter character)
 {
     StartCoroutine(_CrossDoor(character));
     agent = character.GetComponent<UnityEngine.AI.NavMeshAgent> ();
 }