This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

first sorry for my broken english and thanks for reply.

how can i switch between female and male player?
i dont know to explain it but, i make female(player) that i can customize all part like body/hair/eyes/skin and etc. now i want to switch to male(player) by click male button, which is different hair/body etc. how should i do it?

do i need to do it all in same script then i put all female code under func femaleready() and make other func maleready() then switch this two. witch is im not sure how to do it.

or should i make other scene and switch between female and male scene?

or there other way like switch load() folder?
i mean like "res://player/female" to ""res://player/male"

this my code

func _ready():
randomize()
hair_ready()
top_ready()
bottom_ready()
skin_ready()

func _process(delta):
hair_rbg_box()
top_rbg_box()
bottom_rpg_box()
skin_RGB_box()

########################hair###################################################################################
func hair_ready():
    ####### hair display at first play scence#########

    $player/hair.set_texture(load("res://player/female/hair/Fhair"+str(randi() % 6 + 1)+".png"))
    red = $hairRGB/R/Red_scrollbar.set_value(randi() % 255 + 1)
    green = $hairRGB/G/Green_scrollbar.set_value(randi() % 255 + 1)
    blue = $hairRGB/B/Blue_scrollbar.set_value(randi() % 255 + 1)

func hair_rbg_box():


    #value RGB 255/255 = 0 / 1
    red = $hairRGB/R/Red_scrollbar.value / 255
    green = $hairRGB/G/Green_scrollbar.value / 255
    blue = $hairRGB/B/Blue_scrollbar.value / 255

    #display value RGB
    $hairRGB/R/Red_scrollbar/value.set_text(str($hairRGB/R/Red_scrollbar.value))
    $hairRGB/G/Green_scrollbar/value.set_text(str($hairRGB/G/Green_scrollbar.value))
    $hairRGB/B/Blue_scrollbar/value.set_text(str($hairRGB/B/Blue_scrollbar.value))

    $player/hair.set_modulate(Color(red,green,blue))


func _on_hairbox_left_pressed():


func _on_hairbox_right_pressed():

func set_player_hair_style():
in Engine by (429 points)

is male hair also Fhair, or is it Mhair?

Mhair, should i change both to hair only?

1 Answer

+1 vote
Best answer

I would recommend that both hairs are claled "hair" instead of Mhair and Fhair.
Then i would create a variable that initially gets female value. When gender button is pressed, i would change the variable to male, and reload the resource.. something like this:

var gender = "female" #at the beggining

func hair_ready():
####### hair display at first play scence#########

    $player/hair.set_texture(load("res://player/"+gender+"/hair/hair"+str(randi() % 6 + 1)+".png"))
    red = $hairRGB/R/Red_scrollbar.set_value(randi() % 255 + 1)
    green = $hairRGB/G/Green_scrollbar.set_value(randi() % 255 + 1)
    blue = $hairRGB/B/Blue_scrollbar.set_value(randi() % 255 + 1)

# ALL the rest your code remains equal #

func _on_GenderButton_pressed():
    if gender == "female":
        gender = "male"
    else:
        gender = "female
    hair_ready()

or something like that. Don't forget to create GenderButton and connect its pressed to _on_GenderButton_pressed

by (3,505 points)
selected by

thank you very much, i just try it, work perfectly like i want too.

You are welcome! im glad to help

sorry i bother you again, since female and male have different type hairstyle, female have 6 type and male have 3 type. i try to make var femalehairstyle = 6 and malehairstyle = 3 but it seem i cant just put ""+ gender+"hair_style".
im sorry i really new at code

func hair_ready():
    ####### hair display at first play scence#########


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

Should that be str(femalehairstyle) since it is an int?

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.