Previous Thread  Next Thread

chat icon Start/Stop Music Code Help

Zoeo

Posted: Wed Aug 08, 2012 7:48 pm
Joined: 12 Feb 2012
Posts: 13
Okay so I'm trying to test a code so that when my "Cube" or player or cursor or whatever is near the Empty, it will turn the music on or off, so far I've been unsuccessful, I'm very new to coding and need some help Confused

Here's the code I tried:
Code:
import bge


def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner
    player = bge.logic.getCurrentObject('Cube')

    sens = cont.sensors['Play']
    actu = cont.actuators['Music']
   
    sens.distance = 0.50

    if sens.positive:
        cont.activate(actu)
    else:
        cont.deactivate(actu)

main()
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group