Skip to content

Instantly share code, notes, and snippets.

@Jeremi360
Created April 16, 2019 07:46
Show Gist options
  • Save Jeremi360/9bcf9424cddb5b0fb11e564f8fe66a5f to your computer and use it in GitHub Desktop.
Save Jeremi360/9bcf9424cddb5b0fb11e564f8fe66a5f to your computer and use it in GitHub Desktop.
black hole for my friend
extends Area
# I write this with out godot - it can have small errors
export var suck_speed = 5
var objects_in = []
func _ready():
connect("body_entered", self, "on_body_enter")
func on_body_enter(body):
if not (body in objects_in):
objects_in.append(body)
func _physic_process(delta):
if objects_in.size() == 0:
return
for obj in objects_in:
## this move obj for its current postion to black hole postion with suck_speed
obj.translation = lerp(obj.translation, translation, dealta * suck_speed)
## this will remove object if it is in center of black hole
if obj.translation.distance(translation) == 0:
objects_in.erase(obj)
obj.queue_free()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment