![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | RexinBeast |
I need a enemy for my character, could anybody help me create my enemy. I am new to Godot, I just picked up the engine a few days ago. When my enemy is touched, I would like my player to disappear, and when my enemy’s head is jumped on, I would like my enemy to disappear. Here is the code I used for my player:
extends KinematicBody2D
var score : int = 0
var speed : int = 200
var jumpforce : int = 490
var gravity : int = 800
var vel : Vector2 = Vector2()
onready var sprite : Sprite = get_node(“Sprite”)
func _physics_process(delta):
vel.x = 0
if Input.is_action_pressed("move_left"):
vel.x -= speed
if Input.is_action_pressed("move_right"):
vel.x += speed
vel = move_and_slide(vel, Vector2.UP)
vel.y += gravity * delta
if Input.is_action_just_pressed("jump") and is_on_floor():
vel.y -= jumpforce
if vel.x < 0:
sprite.flip_h = false
elif vel.x > 0:
sprite.flip_h = false
I hope this helps! Thank you Godot Community!
Edit: I do not know how to make the code go into the box thing