0 votes

how to make an event happen when a certain velocity is hit?

in Engine by (55 points)

You'll have to be more specific. What velocity are you interested in? One of your own or the one reported by get_linear_velocity()? Also what axis are you interested in? X or Y? Or did you want to measure magnitude? Then what do you consider an "event"? A custom signal?

It sounds like an if statement.

if velocity == x: # or , >=, <=, <, >

But maybe you want something else.
Give us more details, as avencherus said.

when the player( rigidBody ) if falling so -y axis and hits 0,-200: the scene will reload. oke?

1 Answer

0 votes

A basic example for that would be:

extends RigidBody2D

func _ready():

const MAX_VELOCITY = 200

func _fixed_process(delta):
    if(get_linear_velocity().y > MAX_VELOCITY):
        print("Do reload here")
by (5,266 points)

sorry, but there is an error it says: Invalid operands 'float and 'nil' in operator '>'.

no, thanks for helping!

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.