WASD keys to move and aim with the mouse, left mouse button to shoot.

Technical Content

Lecture Content

Here are three functions used in the prototype:

  •  void OnButtonClicked()


    • This function is called when a button is clicked. The buttons in the upper left reset the game.
  •  public void Move(Vector3 _velocity)
    • The purpose of this code is to set a velocity vector for the player's movement, indicating the speed and direction of the movement. When this method is called, it updates the value of the velocity variable. Then, in FixedUpdate(), velocity is used to move the object, using the rigid body's MovePosition() method for smooth physical movement.
  • IEnumerator UpdatePath()
    • In the IEnumerator Attack() method, yield return null is used in a while (percent <= 1) loop. This loop controls the gradual movement of the enemy from its current position to the target of the attack, and applies damage during the attack. Each loop pauses execution by yield return null and waits for the next frame to update before continuing with the next loop. This allows enemy attack animations or behaviors to execute smoothly over multiple frames. (Since the computer executes this method 60 frames a second in the update method, but this causes the ai to repeat the execution of the motion of solving the enemy in an unsmooth manner, I have it execute it at intervals to balance this out)

Creative Content:

Learnings: 

I tried to use the mouse to click on the floor as the player's movement last semester, but the method at that time was rather redundant and not concise this time, I researched on the Internet and re-learned the ray cast method to start from the camera to make a ray on the plane, and then this ray's fall position information as the player's reference to shoot and face direction, I'm very I'm glad I finally got the operating system smooth this time.

Ray ray = viewCamera.ScreenPointToRay(Input.mousePosition);

            Plane groundPlane = new Plane(Vector3.up, Vector3.zero);

            float rayDistance;

            if (groundPlane.Raycast(ray, out rayDistance))

            {

                Vector3 point = ray.GetPoint(rayDistance);

                //Debug.DrawLine(ray.origin, point, Color.red);

            controller.LookAt(point);

            }

Iteration: 

Color differentiation between enemies and players, as well as enemy attack animations (accelerated bursts and color changes)

Balance:

Adjusted the speed of enemy generation for each wave, after my friend and I tested it, the number of enemies generated at the beginning was so low and slow that the player didn't find it enjoyable to play, so I lowered the interval and speed of the pistol's bullets, as well as increased the speed of enemy generation.

Communication Feedback:

Because some players reacted to the perspective can not see all so, adjusted to enlarge the game map.

Leave a comment

Log in with itch.io to leave a comment.