Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     // Implement motion
     if (should_move_forward())
     {
         move_forward();
     }
     if (should_move_backward())
     {
         move_backward();
     }
     if (should_strafe_left())
     {
         strafe_left();
     }
     if (should_strafe_right())
     {
         strafe_right();
     }
     if (should_turn_left())
     {
         turn_left();
     }
     if (should_turn_right())
     {
         turn_right();
     }
     if (should_sprint_forward())
     {
         sprint_forward();
     }
     if (should_dodge_left())
     {
         dodge_left();
     }
     if (should_dodge_right())
     {
         dodge_right();
     }
     if (should_jump())
     {
         jump();
     }
     fireElapsedTime += Time.deltaTime;
     if (Input.GetButton("Fire1") && fireElapsedTime >= fireCooldown)
     {
         fireElapsedTime = 0;
         shoot_at(cross_hair);
     }
     elevation_angle = Mathf.Clamp(elevation_angle, -45f, 10f);
     cross_hair.update_elevation(elevation_angle);
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // Implement motion
        if (should_move_forward())
        {
            move_forward();
        }
        if (should_move_backward())
        {
            move_backward();
        }
        if (should_strafe_left())
        {
            strafe_left();
        }
        if (should_strafe_right())
        {
            strafe_right();
        }
        if (Input.GetButton("Fire1"))
        {
            shoot_at(cross_hair);
        }

        turn(Input.GetAxis("Horizontal"));

        elevation_angle -= Input.GetAxis("Vertical");
        elevation_angle  = Mathf.Clamp(elevation_angle, -85f, 40f);
        cross_hair.update_elevation(elevation_angle);



        if (should_sprint())
        {
            sprint_forward();
        }
    }