[ad_1]
Sport Improvement Stack Trade is a query and reply website for skilled and unbiased sport builders. It solely takes a minute to enroll.
Anyone can ask a query
Anyone can reply
The perfect solutions are voted up and rise to the highest
Requested
Considered
6 occasions
$begingroup$
extends CharacterBody2D
@export var SPEED = 300.0
@export var maxHP = 100
@export var curHP = 100
var gravity = ProjectSettings.get_setting("physics/2nd/default_gravity")
var state_machine = $AnimationTree.get("parameters/playback")
func _ready():
move
func _physics_process(delta):
if not is_on_floor():
velocity.y += gravity * delta
var course = Enter.get_axis("ui_left", "ui_right")
if course:
velocity.x = course * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if velocity.size() > 0:
state_machine.journey("run")
else:
state_machine.journey("idle")
if Enter.is_action_pressed("ui_left"):
$Sprite2D.set("flip_h", true)
if Enter.is_action_pressed("ui_right"):
$Sprite2D.set("flip_h", false)
move_and_slide()
if Enter.is_action_just_pressed("assault"):
_shoot()
func _losehp():
curHP -= 10
func _die():
if curHP == 0:
move
func _shoot():
if Enter.is_action_just_pressed("assault"):
move
please assist:(
$endgroup$
default
[ad_2]