2
$\begingroup$

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

$\endgroup$

2 Answers 2

1
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .