I'm making an arcade game and I have some hexagons that when you hit them the game restarts, I want them to spin, I want them to keep moving left, when you press D it moves right and when you press A it moves left, I also want it to teleport back so when the hexagons pass the black border it teleports back to the other side.
I can't find any information on how to do it so any of you know?
This is the code for the hexagon:
extends KinematicBody2D
func _on_Area2D_body_entered(body):
if body.get("TYPE") == "player":
get_tree().reload_current_scene()
This is the code for the player:
extends KinematicBody2D
const TYPE = "player"
var speed:= 500.0
func _ready():
pass
func _process()delta:
look_at(get_global_mouse_position())
var direction = self.get_global_transform().origin.direction_to)get_global_mouse_position())
if !self.get_global_transform().origin.distance_to((get_global_mouse_position())) < 5.0:
move_and_slide(direction * speed)