0 votes

what i want is to change var femalehairstyle to var malehairstyle or change var "male" to "female"hairstyle in
str(randi() % femalehairstyle + 1)

var femalehairstyle = 6
var malehairstyle =3
var gender = "female"

    $player/hair.set_texture(load("res://player/"+gender+"/hair/hair"+str(randi() % female_hair_style + 1)+".png"))

func _on_female_pressed():
    if gender == "male":
        gender = "female"
in Engine by (423 points)

1 Answer

+1 vote
Best answer

Well, asuming that you also have a _on_male_pressed function where you change gender to male i would do the same logic that to change gende:

var female_hair_style = 6
var male_hair_style =3
var gender = "female"
var hair_style = female_hair_style

$player/hair.set_texture(load("res://player/"+gender+"/hair/hair"+str(randi() % hair_style + 1)+".png"))

func _on_female_pressed():
    gender = "female"
    hair_style = female_hair_style

func _on_male_pressed:
    gender = "male"
    hair_style = male_hair_style

Notice i used hair_style with randi

by (3,503 points)
selected by

omg! thank you very much, today i spent all my time to figure it out how to do it right, but never success. you really are my hero, thank you.

You are welcome!

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.