Visibility Actuator problem

hello guys i just moved from 2.48 to 2.49 and the visibility actuator is kinda diferent but thats not a problem i guess,the problem is the following:

mageVisible = cont.getActuator(“mageVisible”)

if own.armor == 0:
	g.addActiveActuator(mageVisible,1)
else:
	g.addActiveActuator(mageVisible,0)

so if property armor is equal to 0 then mage (an object) goes visible and if is not equal to 0 then it should go invisible…

now i dont know what im doing wrong but it dosnt go invisible when its on 0 :S

BGE Python API documentation:
http://www.blender.org/documentation/249PythonDoc/GE/index.html

This should work:


mageVisible = cont.actuators["mageVisible"]

if own["armor"] == 0: 
    mageVisible.visibility = 1 
else: 
   mageVisible.visibility = 0

cont.activate(mageVisible)

If not, you need to post the resulting console output (I asked for that in the last thread you made…for the very same problem).

My abd social, but i couldnt find the console on my mac im still trying to figure out too, and yeah i guess your code works but theres a little problem, let me exaplain:


mageVisible = cont.actuators["mageVisible"]

if own["armor"] == 0: 
   mageVisible.visibility = 1 
else: 
   mageVisible.visibility = 0

cont.activate(mageVisible)

warriorVisible = cont.actuators["warriorVisible"]

if own["armor"] == 1: 
   warriorVisible.visibility = 1 
else: 
   warriorVisible.visibility = 0

cont.activate(warriorVisible)

Okey so now lets say that if i press ARROWKEY UP property armor will add 1 int and if i press ARROWKEY DOWN it will rest 1 int.

so yeah, if armor = 0 Mages has to appear and if armor = 1 warrior has to appear

so the problem here is that when i start the game engine, they both appear…(even tho armor = 0)

and then when i press ARROWKEY UP warrior appears (correctly) then i press ARROWKEYDOWN and mage appears(correctly)

so the problem is that when i first start the engine they both appear even tho only the mage is supposed to appear (because property armor is = to 0 ) :S

Heh, that’s the funny thing here: You can’t figure out how to do that, yet you’re trying to make a game.

Even with blender, game development is still software development, and software development is difficult.

Launching blender from terminal is something you should figure out before you start developing a game.

so the problem is that when i first start the engine they both appear even tho only the mage is supposed to appear (because property armor is = to 0 ) :S
First: Figure out how to launch blender from console.

(Hint: Try opening up the terminal application, and typing “blender” - no quotes)

Then: I’ll show you how to debug your code.

EVERYONE ELSE:

I can’t tell people what to do, but I wouldn’t recommend just giving him the answer, because ultimately, you’re not going to help him that way.

i develop my games on my PC i dont use this mac much thats probably the reason why i dont know how to start the console , u sayd you never used a mac so u got no idea, well i got no idea either, so you shouldnt be talking :wink: .

i will tell You when i get to start the console.

Then why are you using a mac? Go back to your PC, and find out what the console outputs (if anything).

u sayd you never used a mac so u got no idea, well i got no idea either, so you shouldnt be talking :wink: .
:rolleyes:

This is what I said in the previous thread: “I don’t own a mac, but I’m sure there’s a ‘Start from terminal’ option for every application. Try to find that, and enable it.”

I work primarily on Linux machines, and those systems, like the mac, don’t launch blender with the terminal automatically. It was something I had to enable, and I did. -> It wasn’t brain surgery (not even on linux).

Im using Mac and PC at the same time because My dad Works with them the Whole time, when he uses 1 i use the other 1 , like that on and on ;), but What eve,r ill try to figure it out if i have some time and ill tell u :wink:

okm i found the Terminal option , but i cant make blender start from the console, i dont know how to, i looked it up on google and forums but i dindt find a way to start it , i will keep looking :wink:

ok i already fixed it, by starting it from the terminal you dont get a console,you ahd to do it a different way, but yeah i got it to work now , and no , it dosnt give me and no, it does not give me any errors on the console :l

ok i already fixed it, by starting it from the terminal you dont get a console,you had to do it a different way, but yeah i got it to work now , and no , it does not give me any errors on the console :l

Add the following line at the end of your script - right after cont.activate(warriorVisible):

print “Hello there”

Start game, then stop game (press no other keys), then look in console.

What do you see printed?

addActiveActuator(mageVisible,0) and
cont.activate(warriorVisible) do not make the the object invisible.

All it does it activates/Deactivates ONE actuator. The visibility actuator will not make your object visible when you deactivate them.

There are multiple solutions:

I hope it helps