Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # PlayerRB.gd
- extends RigidBody2D
- # Constants with CAPS, good practice
- const GRAVITY = 20
- const MAX_SPEED = 200
- var motion = Vector2()
- # A loop called every frame
- func _physics_process(delta):
- motion.y += GRAVITY
- if Input.is_key_pressed(KEY_RIGHT):
- motion.x = MAX_SPEED
- elif Input.is_key_pressed(KEY_LEFT):
- motion.x = -MAX_SPEED
- else:
- motion.x = 0
- #if is_on_floor():
- # if Input.is_action_pressed("ui_up"):
- # motion.y = JUMP_HEIGHT
- # if friction == true:
- # motion.x = lerp(motion.x, 0, 0.2) # 0.2 = 20%
- #else:
- # if friction == true:
- # motion.x = lerp(motion.x, 0, 0.05) # 0.05 = 5%
- set_linear_velocity(motion)
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement