Пример #1
0
    void Update()
    {
        gameController = GameObject.Find("Spotlight");

        SpotlightController controllerscript = (SpotlightController)gameController.GetComponent("SpotlightController");

        timer -= Time.deltaTime;

        WinText.text = "Laps Remaining: " + laps.ToString();

        TimeText.text = "Time: " + timer.ToString();

        if (timer <= 0)
        {
            WinLose.text = "You Lose!";
            gameObject.SetActive(false);
        }

        if (Input.GetKeyDown("f"))
        {
            if (speed < 2)
            {
                speed = speed + 0.5f;
            }
        }

        if (Input.GetKeyDown("r"))
        {
            if (speed > 0.5)
            {
                speed = speed - 0.5f;
            }
        }

        if (Input.GetKey("up"))
        {
            if (overlap == 0)
            {
                spcontrol = -speed * Time.deltaTime;

                spcontrol = (spcontrol + 360) % 360;

                circleAngle += speed * circleSpeed * Time.deltaTime;

                circleAngle = (circleAngle + 360) % 360;

                float newPositionX = circleRadius * (float)Mathf.Cos(circleAngle);

                float newPositionZ = circleRadius * (float)Mathf.Sin(circleAngle);

                Vector3 newPosition = new Vector3(newPositionX, transform.position.y, newPositionZ);

                Vector3 newDirection = newPosition - transform.position;

                newDirection.Normalize();

                float rotationAngle = -Vector3.Angle(lastDirection, newDirection);

                gameController.transform.Rotate(Vector3.up, rotationAngle, Space.World);

                transform.Rotate(Vector3.up, rotationAngle, Space.World);

                transform.position = newPosition;

                lastDirection = newDirection;
            }
        }

        if (Input.GetKey("right"))
        {
            transform.Rotate(Vector3.forward, selfRotationSpeed * Time.deltaTime, Space.Self);
        }

        if (Input.GetKey("left"))
        {
            transform.Rotate(Vector3.back, selfRotationSpeed * Time.deltaTime, Space.Self);
        }
    }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     parent       = GetComponentInParent <SpotlightController>();
     spotCollider = GetComponent <Collider>();
 }