how can i switch between female and male player?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatobanana

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 female_ready() and make other func male_ready() 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():

is male hair also Fhair, or is it Mhair?

p7f | 2019-01-08 17:46

Mhair, should i change both to hair only?

potatobanana | 2019-01-08 18:03

:bust_in_silhouette: Reply From: p7f

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

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

potatobanana | 2019-01-08 20:03

You are welcome! im glad to help

p7f | 2019-01-08 20:04

sorry i bother you again, since female and male have different type hair_style, female have 6 type and male have 3 type. i try to make var female_hair_style = 6 and male_hair_style = 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"))

potatobanana | 2019-01-08 20:53

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

sxkod | 2019-01-08 21:01