# Visibility ON/OFF in the BGE via Python

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.

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:
own.setVisible(True)
else:
own.setVisible(False)


That way you don't need the visibility actuator.