I'm trying to make a simple Asteroid game with the BGE, using Python when necessary. I want to make 'visible' the ship trails when I press 'W' to increase the speed and make them 'invisible' if 'W' is not pressed. Where is the error? I'm very new with Python scripts. see the screen shot


You can do:

own['trails'] = trailsObject
own['trails'].visible = True
own['trails'].visible = False

or as i can see in the image:

cont.activate(trails) # to activate the actuator
cont.deactivate(trails) # to deactivate the actuator

Also visit the BGE Documentation.

Next time please take a moment to copy your code as text and format it.


You should have own.setVisible not setVisibility.

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
wKey = cont.sensors['wKey']

if wKey.positive:

That way you don't need the visibility actuator.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.