first sorry for my bad english.
At the moment i am creating a game with the blender game engine.
I finished all the main features, but to give the game a purpose i want to create an item shop.
I want the user to be able to buy new designs.
I only used 2 global materials, which i named âFloorâ and âBlackâ.
Now i just animated the color on the timeline using keyframes, because i thought i can recall this animation using the âActionâ Logic Brick. This WORKS. BUT!!! In my game i am spawning 6 objects every second.
Every time the object is spawned it changes the color to the default one. So i can not just change the âParentâ Object.
So just for the design i have to:
Check another objects variable for the design keyframe
Execute an action on the âFloorâ material
Execute an action on the âBlackâ material
on every object i spawn.
This destroys the framerate (from 60 to 30 fps) and because blenders logic bricks are bound to the frame rate this slows down the whole game. (And thats not what i want because it is a game about speed.)
So is there any simple way to change the global current frame? So i can just change the design without destroying the framerate?
Or a more efficient way?
Thanks for your answers
(I am also using python, so if there is any solution with python please tell me)
To change object color in game I typically just enable Object Color in the Options settings for the material. Each object has a obj.color = [r, g, b, a] property which will then be enabled on the material.
Is this something you were looking for? It is not fully clear to me what you want to achieve.
Hey maybe I was not clear enough.I have an object with 2!!! Materials applied.Now I want to change BOTH materials on ONE object dynamically on runtime.When I use the âobject colorâ I canât use MULTIPLE materials.Thatâs why I am searching for a way change BOTH.Maybe itâs possible using textures? Is there any way to change the UV Coordinates of a mesh on runtime?
You can also do a lot of cool stuff with node materials. If you start out with a material using object color you can separate the RGB channels and basically have 3 channels to influence anything in the material layout. E.g. mapping 1 channel per submaterial to a color ramp.
Delete and assign the material new, otherwise the order of the first and second material can be wrong.
from bge import logic
own = logic.getCurrentController().owner
own.meshes[0].materials[0].diffuseColor = 0.5, 0.0, 0.5 #change material color (RGB) 1
own.meshes[0].materials[1].diffuseColor = 0.0, 0.5, 0.0 #change material color (RGB) 2
Woooooowww HG1 does this work on runtime??? This would be AMAZING! I will test it when I am at home
And Wraaah, I did not even know that you can use Node Materials in the game engine good to know, I will give it a try