0 votes

Hello! I am a beginner in game engines, godot is the first one i used. I have used this game engine for like 3days now, and i am trying to make a customization menu. The problem is the hair sprites have different dimensions,because the player can choose from either very long hair or very short.
I have a variable called "hairnum" for the model of hair. For example, for hairnum=1 i want the y position to be 15, and for hairnum=2 i want the y position to be 20. How do i do that? I tried searching on youtube or chrome but i didn't really understand. I'm saying again that i do not know a lot, i am only at the beginning, so i appreciate any help.

asked 6 days ago in Engine by Sakura37 (17 points)

1 Answer

0 votes
Best answer

You could make an array with the y positions in it

var hair_positions = [15, 20, ...]

then if hairnum changes get the position

sprite.position.y = hair_positions[hairnum]

Note that hairnum has to be 0 to get the first position in the array, 1 for the second and so on. Or subtract 1 like

sprite.position.y = hair_positions[hairnum-1]
answered 6 days ago by Adam_S (132 points)
selected 4 days ago by Sakura37
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 How to use this Q&A? before posting your first questions.