Created
April 16, 2019 07:46
-
-
Save Jeremi360/9bcf9424cddb5b0fb11e564f8fe66a5f to your computer and use it in GitHub Desktop.
black hole for my friend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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