Skip to content

Instantly share code, notes, and snippets.

@febret
Created June 28, 2013 16:31
Show Gist options
  • Save febret/5886038 to your computer and use it in GitHub Desktop.
Save febret/5886038 to your computer and use it in GitHub Desktop.
Getting a wand position
# Example 1: Get wand position using the event function
onEvent():
e = getEvent()
if(e.getServiceType() == ServiceType.Wand())
wandPosition = e.getPosition()
# use wandPosition to do stuff here or save it in
# a global var and do stuf later
setEventFunction(onEvent)
#----------------------------------------------------
# Example 2: attach an object to the wand trackable.
# Make it visible when it's above 1.5 meters.
sphere = SphereShape.create(1,2)
sphere.followTrackable(1) # CAVE2 main wand it trackable #1
onUpdate(frame, time, dt):
# if sphere is 1.5 meters above ground, make it visible
if(sphere.getPosition().y - getDefaultCamera().getPosition().y):
sphere.setVisible(True)
else:
sphere.setVisible(False)
setUpdateFunction(onUpdate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment