Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | LJ INFINITY |
so yeah i want make a simple weapon switching system and i cant seem to figure it out please help me
my entire code:(do you mind looking at the whole code while u r at it cause i made most of it myself and dont know if its good)
extends KinematicBody2D
var speed = 250
var GRAVITY = 600.0
var velocity = Vector2()
var jumpforce = -350
var hand = false
var sword = false
var sword_obtained = false
var bow_obtained = false
func _ready():
hand = true
func _process(_delta):
velocity.y += _delta * GRAVITY
if Input.is_action_pressed("left"):
velocity.x = -speed
if is_on_floor():
if sword_obtained == false:
$AnimatedSprite.play("run")
$AnimatedSprite.flip_h = true
elif Input.is_action_pressed("right"):
velocity.x = speed
if is_on_floor():
if sword_obtained == false:
$AnimatedSprite.play("run")
$AnimatedSprite.flip_h = false
else:
velocity.x = 0
if is_on_floor():
if sword_obtained == false:
$AnimatedSprite.play("idle")
elif sword_obtained == true:
$AnimatedSprite.play("idle_sword_obtained")
elif sword == true:
$AnimatedSprite.play("idle_sword")
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jumpforce
if sword_obtained == false:
$AnimatedSprite.play("jump")
if is_on_floor() == false:
speed = 300
if is_on_floor():
speed = 250
if Input.is_action_pressed("ui_down"):
GRAVITY = 1200.0
elif Input.is_action_just_released("ui_down"):
GRAVITY = 600.0
move_and_slide(velocity, Vector2(0, -1))
if Input.is_action_just_pressed("hand"):
hand = true
sword = false
if Input.is_action_just_pressed("sword") and sword_obtained == true:
hand = false
sword = true
if Input.is_action_just_released("sword") and sword_obtained == true:
$AnimatedSprite.play("sword_draw")
func pickup():
if Input.is_action_just_pressed(“take”):
sword_obtained = true
func _on_Area2D_body_entered(body):
if “pedestal” in body.name:
pickup()
and BTW i’m new to this engine and gamedev stuff