Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- var velocity = Vector2(6,0)
- const gravity = Vector2(0,1)
- func _ready():
- set_fixed_process(true)
- pass
- func _fixed_process(delta):
- velocity += gravity * delta
- move(velocity)
- think we are good
- thanks this room is a lifesaver
- Ross - Today at 4:53 PM
- Imagine you are only processing once every second. Gravity is an acceleration. Every second you move that much faster than the previous second. So velocity gets gravity added in every second. And velocity is in pixels per second, it's how far you move every second.
- So if you were processing 4 times a second, delta would be 0.25 seconds. So you only want to add 0.25 gravity to velocity, etc.
- extends KinematicBody2D
- var velocity = Vector2(100,0)
- const gravity = Vector2(0,30)
- func _ready():
- set_fixed_process(true)
- pass
- func _fixed_process(delta):
- velocity += gravity *delta
- move(velocity*delta)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement