0 votes

I added a bomb that constantly goes up in a physics_process function. The player has the ability to slow down time, and when they do it changes the engines timescale to 0.05. When the player slows down time everything in the game except the bomb slows down.

Here is the code:

extends Area2D

func _physics_process(delta):
    if Engine.time_scale <= 0.05:
        global_position = global_position + Vector2(0,-0.25)
    else:
        if Engine.time_scale >= 0.05:
            global_position = global_position + Vector2(0,-1)
Godot version 3.3.3
in Engine by (14 points)

1 Answer

+2 votes

Hello! You have to multiply the value that you add to the global_position variable by the delta parameter on the function.

For example:

global_position += Vector2(0, -0.25) * delta

This "delta" is what ensures that the speed of the object will be consistent with the time_scale and won't vary based on things like framerate.

Hope this helps!

by (56 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.