moving object forward backward
When the mouse is pointed at the object I want to move it depending on wich key i press. A normal int number works but example +=0.5 does not work.
Code: Code:
cube = vizshape.addCube() |
hello,
the setPosition command accepts lists in [x,y,z] format so try object.setPosition([pos,0,0]). if you're trying to go forward and backward, that's normally along the z-axis so you might want to change it to ([0,0,pos]). Masaki |
That is not working. This is the error I get:
Traceback (most recent call last): File "C:\Program Files (x86)\WorldViz\Vizard30/python\vizact.py", line 3019, in __onkeydown self._callGroup(self.__keydownmap[key]) File "C:\Program Files (x86)\WorldViz\Vizard30/python\vizact.py", line 2971, in _callGroup val = e.call(arg) File "C:\Program Files (x86)\WorldViz\Vizard30/python\vizact.py", line 2794, in _callStatic return func(*args,**kwargs) File "Test wall.py", line 39, in moveForward pos += 0.5 UnboundLocalError: local variable 'pos' referenced before assignment My code: Code:
def moveForward(): |
You need to assign a value to pos before you add to it:
Code:
import viz |
Tnx it worked. Tnx for your time
|
All times are GMT -7. The time now is 06:06 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC