Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Move Your Player | Player Behavior
Fighting Game in Unity
course content

Course Content

Fighting Game in Unity

Fighting Game in Unity

1. Unity Animation System
2. Player Behavior
3. Enemy Behavior
4. Improve the Game
5. Improve the Flappy Bird Game

book
Move Your Player

FixedUpdate and Update

Update()

The Update() method, called once per frame, handles regular updates like player input and user interaction. Its execution frequency varies with the frame rate, leading to potential inconsistencies across devices.

FixedUpdate()

The FixedUpdate() method, called at fixed intervals, is ideal for physics-related updates, providing reliable and predictable handling of forces, collisions, and movement.

Use Update() for regular updates that don't involve physics, like checking for user input or updating animations. Use FixedUpdate() for physics-related updates, like moving objects with Rigidbody or handling collisions, to ensure smoother and more reliable behavior.

Movement Code

The code snippet involves various checks and assignments to control the movement of a game character. It starts by checking if the horizontal movement variable x is not zero and then creates a Vector2 variable to store the Rigidbody component's current velocity. It also verifies if the current animation is not "attack" to determine if the character is in an attacking state. If not attacking, it sets the horizontal velocity based on the input, elapsed time, and speed; otherwise, it stops horizontal movement. Finally, it updates the Rigidbody's velocity with the new values.

Which method is typically used for handling physics calculations and updates?

Which method is typically used for handling physics calculations and updates?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 1
We're sorry to hear that something went wrong. What happened?
some-alt