Пример #1
0
    // Called on the update when the state is Move
    private void MoveControl()
    {
        if (Input.GetKeyDown("space"))
        {
            this.currentState = States.BallStates.Rotate;
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            Vector3 position = this.transform.position;
            position.x -= MoveSpeed;
            this.transform.position = position;
        }

        if (Input.GetKey(KeyCode.RightArrow))
        {
            Vector3 position = this.transform.position;
            position.x += MoveSpeed;
            this.transform.position = position;
        }
    }
Пример #2
0
    private void DirectionControl()
    {
        if (Input.GetKeyDown("space"))
        {
            rb.AddForce(transform.forward * thrust);
            this.currentState = States.BallStates.Roll;
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            Vector3 position = this.transform.position;
            position.x -= MoveSpeed;
            this.transform.position = position;
        }

        if (Input.GetKey(KeyCode.RightArrow))
        {
            Vector3 position = this.transform.position;
            position.x += MoveSpeed;
            this.transform.position = position;
        }
    }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     this.rb            = GetComponent <Rigidbody>();
     this.currentState  = States.BallStates.Move;
     this.ShotDirection = transform.forward;
 }