A little bit complicated!

So im making a game with a flashlight, and there are different “Flashlight Skins” which you can equip!
But because I dont want to rewrite the “code” in every level if I add a new flashlight, I tried to do:
FlashlightSkin (Global Variable)= 1 Set animation of Flashlight to GlobalVariable(FlashlightSkin).
But there is a problem: if I want to change the colour of the light of the flashlight, i have to type in the “colour code” (The R;G;B number). How can I do this automatically by using my Global Variable FlashlightSkin (which is a number)? For questions to this question, I know its hard to understand, just comment or reply to this, I will answer it in a few minutes if im online. Please help!

Hi there,
You can make an event at start of scene to check what flashlight mode is selected. 1, 2, 3 …
If flashlightMode == 1, flashlight color rgb(255,255,255)
If flashlightMode == 2, flashlight color rgb(255,200,240)

Basically, make condition to check the flashlight mode and then set the colour associated with that mode.

1 Like

Thank you, but the problem is that this event has to be in every new level what I add for example: I add level 10 and a new flashlight, so I have to paste the line: if flashlightskin == 1…
In every level an szene before. Is there maybe any way to make this line of code like „global“ oder something you know? If you don’t know, thanks for your help anyway!

Store the flashlight number and the corresponding RGB string in a structure. Use the flashlight number as the key, and the RGB string as the value:


Then just access it with:

image

2 Likes

Thank you, thats what I needed!

1 Like