0 votes

i am trying to pick a random image for a sprite but it keeps picking only the last the one.
what am i doing wrong?

extends KinematicBody2D


var new_anim
var anim
var state
var loading_player

var dak_image = preload("res://assets/transparent/dak-player.png")
var hugo_image = preload("res://assets/transparent/hugo-player.png")
var roger_image = preload("res://assets/transparent/roger-player.png")

onready var player_texture = get_node("Sprite")

# Called when the node enters the scene tree for the first time.
func _ready():

func random_player():
    var image_players = [dak_image, hugo_image, roger_image]
    var name = image_players[randi() % image_players.size()]
    $Sprite.texture = (name)

func change_state(new_state):
    state = new_state
    match state:
            new_anim = 'idle'
            new_anim = 'move' # links en rechts bewegen en naar 
            new_anim = 'hurt'
            dead() #deze functie nog maken
in Engine by (21 points)

1 Answer

0 votes

To answer my own questing i forgot to add

by (21 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.