You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

1 D铆as
10 Hrs
1 Min
19 Seg
Curso de Introducci贸n a Unity: Scripting

Curso de Introducci贸n a Unity: Scripting

Ruth Margarita Garc铆a L贸pez

Ruth Margarita Garc铆a L贸pez

Creando movimiento independiente del framerate

15/24
Resources

How does the frame rate impact the development of a game?

The development of a video game requires understanding how the frame rate works, since it is fundamental to ensure a fluid movement of the objects on screen. The frame rate is the amount of images that are rendered per second and is vital to the user experience. If your code depends on the frame rate, you may face problems when system resources are limited.

What happens when implementing a lag script?

A lag script simulates a slow computer, allowing us to observe how the game would behave under different performance conditions. By adjusting this script, we get the computer to pretend to have a low frame rate, thus evaluating how independent our code is of this factor.

  • Caution: Increasing the script parameters too much can freeze the computer.

How do objects move with and without delta time?

To understand the impact of frame rate on object movement, it is important to know how to use delta time in Unity. The difference between moving an object using or not using delta time is crucial to ensure a constant movement regardless of system resources.

Moving objects without delta time

When moving an object without delta time, the movement is done per frame. This means that the distance traveled depends directly on the frame rate:

public class SinDeltaTime : MonoBehaviour{ public float speed = 0.05f; // 5 centimeters per frame
 void Update() { transform.Translate(0, 0, speed); }}
  • Consequence: If the frame rate goes down, the object appears to move slower.

Moving objects with delta time

Using delta time ensures that the space traveled by an object is constant per second, not per frame, regardless of the frame rate:

{public class ConDeltaTime : MonoBehaviour{ public float speed = 5f; // 5 meters per second
 void Update() { transform.Translate(0, 0, speed * Time.deltaTime); }}
  • Benefit: Maintains constant motion regardless of the processing speed of the system.

Why is it crucial to understand the theory behind these concepts?

Understanding the theoretical underpinnings behind motion through delta time is essential, not only because it improves game development, but also because it applies to scaling, growth and many other aspects of programming and animation in Unity.

Practical applications of delta time

  • Scenarios: Control the growth of an object, such as a balloon that increases in size by 10% every second, ensuring the increase is proportional to the elapsed time.
  • Consistency: Ensuring that animations and movements are consistent across any device or limited hardware conditions.

Through these concepts, we not only develop skills to create a game, but strengthen the understanding necessary to innovate and create without relying on pre-existing guidelines or examples. The theoretical knowledge equips you to see beyond and confidently build any mechanic in a virtual environment.

Contributions 10

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?

El paquete de los recursos no es el que dice en el video :(
el mio fue 6.30
Siempre me pregunte para que era el Time.deltaTIme ya entendi todo. Excelente.
yo lo puse al 15 y no bajo de 200 :(

ocupe el mismo numero 6.5

Excelente explicaci贸n y el atajo de teclado fue la cereza del pastel. Gracias! 馃

el numero que con el que me va a 10 fps es 6.34

tambien me dio 6,5

Excelente concejo ya que he hecho algunos tutoriales pero vale mas entender como hacerlo

5.68