Exemplo n.º 1
0
        private void MoveCar()
        {
            if (distanceToTarget < minShootingDistance)
            {
                car.MoveCar(0, 0, 1);
            }

            Vector3 direction = (targetPosition - transform.position).normalized;
            float   steering  = Vector3.Dot(transform.right, direction);
            float   motor     = Vector3.Dot(transform.forward, direction);

            float breakingRange = distanceToTarget - minShootingDistance;

            if (breakingRange < minShootingDistance)
            {
                motor *= breakingRange / minShootingDistance;
            }

            car.MoveCar(motor, steering, 0);
        }
Exemplo n.º 2
0
        // Update is called once per frame
        void FixedUpdate()
        {
            float motor    = carJoystick.Vertical;
            float steering = carJoystick.Horizontal;
            float breaks   = 0;

            if (Mathf.Abs(motor) < .2f)
            {
                breaks = 1;
            }
            car.MoveCar(motor, steering, breaks);

            cannon.RotateCannon(cannonJoystick.Horizontal);
            cannon.ElevateCannon(-cannonJoystick.Vertical);
        }