Yeeeeey

 avatar
TaktycznyBocian
plain_text
2 years ago
573 B
9
Indexable
extends KinematicBody2D

var speed = 200
var velocity = Vector2()

func _physics_process(_delta):
	velocity = Vector2()
	if Input.is_action_pressed("ui_right"):
		velocity.x = velocity.x + 1
	if Input.is_action_pressed("ui_left"):
		velocity.x = velocity.x - 1
	velocity = velocity.normalized() * speed
	velocity = move_and_slide(velocity)
	
	
func _on_Area2D_body_entered(body):
	hide()
	emit_signal("hit")
	$Area2D/CollisionShape2D.set_deferred("disabled", true);

func start(pos):
	position = pos
	show()
	$Area2D/CollisionShape2D.disabled = false
Editor is loading...