20 lines
363 B
GDScript3
20 lines
363 B
GDScript3
|
extends KinematicBody2D
|
||
|
|
||
|
var motion = Vector2(0, 0)
|
||
|
const UP = Vector2(0, -1)
|
||
|
const GRAVITY = 30
|
||
|
export var health : int = 100
|
||
|
|
||
|
func _process_gravity():
|
||
|
if not is_on_floor():
|
||
|
motion.y += GRAVITY
|
||
|
else:
|
||
|
motion.y = 1
|
||
|
if is_on_ceiling():
|
||
|
motion.y = GRAVITY
|
||
|
|
||
|
func _physics_process(delta):
|
||
|
if motion != null:
|
||
|
move_and_slide(motion, UP)
|
||
|
_process_gravity()
|