Skip to content

Instantly share code, notes, and snippets.

@LottieVixen
Created September 13, 2021 09:07
Show Gist options
  • Save LottieVixen/20bdc2a5ffadba118cc849f7244b6e0e to your computer and use it in GitHub Desktop.
Save LottieVixen/20bdc2a5ffadba118cc849f7244b6e0e to your computer and use it in GitHub Desktop.
extends RigidBody2D
var screensize
var centered = false
export (Vector2) var thrust_force = Vector2(15,0)
var forward = 0
func _ready():
screensize = get_viewport().get_visible_rect().size
func _draw():
draw_circle(($Thrusters/Rear.global_position + thrust_force),5,Color.rebeccapurple)
#draw_circle((Vector2(0,0) + thrust_force),5,Color.rebeccapurple)
func _process(delta):
if !($Thrusters/Rear.global_position.y == global_position.y):
print("mismatch")
if Input.is_action_pressed("jump"):
forward = 1
else:
forward = 0
func _integrate_forces(state):
if !centered:
var xform = state.get_transform()
xform.origin.x = screensize.x / 2
xform.origin.y = screensize.y / 2
state.set_transform(xform)
centered = true
add_force($Thrusters/Rear.global_position, thrust_force)
#add_force(Vector2(0,0), thrust_force)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment