Start/Stop Music Code Help

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Zoeo
Posts: 13
Joined: Sun Feb 12, 2012 6:26 pm

Start/Stop Music Code Help

Postby Zoeo » Wed Aug 08, 2012 8:48 pm

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 :?

Here's the code I tried:

Code: Select all

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()

Return to “Coding Blender”

Who is online

Users browsing this forum: YaCy [Bot] and 0 guests