@fire7side said:
Your y is your up and down. You can find the top y and the bottom y by getting the position in the editor and change speed to - when it reaches each one. You don't need gravity so that makes it easier. It's a good programming challenge. You'll be manipulating velocity.y instead of velocity.x.
Got it to work! Well, I kept gravity so it is more of a jumping than a flying one but it's gravity is pretty moon-like so for all intents and purposes it is flying.
I really just changed .x to .y in a couple spots and changed is_on_wall to is_on_floor.
Thanks again :)
extends KinematicBody2D
const FLOOR_NORMAL: = Vector2.UP
export var speed: = Vector2(30.0, 100.0)
export var gravity: = 40.0
export var points: = 5
var velocity = Vector2.ZERO
func _ready():
set_physics_process(false)
velocity.y = -speed.y
func _on_StompDetector_body_entered(body):
if body.global_position.y > $StompDetector.global_position.y:
return
else:
$CollisionShape2D.disabled = true
die()
func _physics_process(delta):
velocity.y += gravity * delta
if is_on_floor():
velocity.y *= -speed.y
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y