#1
|
|||
|
|||
Quick Question
Calling all Vizards,
I am trying to add the ability to mount and dismount a vehicle (FLT) in my scene. When dismounted the user should be able to walk around the environment as normal. Problem is when I only seem to able to perform this action once, maybe I am trying to do this the wrong way . Here is a snippet of code to illustrate the way I am trying to achieve this. Code:
import vizcam def orbitCamera(): cam = vizcam.PivotNavigate(distance=4) cam.centerNode(run) bodyLink.remove() def normalView(): bodyLink = viz.link(body,view,dstFlag=viz.LINK_BODY) bodyLink.preTrans([0,-0.29,0.2]) def buttonTimer(): if joy.isButtonDown (3): vizact.choice([orbitCamera(),normalView()],vizact.LOOP) vizact.ontimer(viz.FASTEST_EXPIRATION,buttonTimer) Thanks for any help in advance, Regards, Nige |
#2
|
|||
|
|||
Are you trying to toggle between the orbit camera and normal view when joystick button 3 is pressed? If so, you will need to modify your code to look something like this:
Code:
import vizcam cam = vizcam.PivotNavigate(distance=4) cam.enabled = False bodyLink = viz.link(body,view,dstFlag=viz.LINK_BODY) bodyLink.preTrans([0,-0.29,0.2]) def joydown(e): if e.button == 3: cam.enabled = not cam.enabled if cam.enabled: bodyLink.disable() cam.centerNode(run) else: bodyLink.enable() viz.callback(vizjoy.BUTTONDOWN_EVENT,joydown) |
#3
|
|||
|
|||
RE: Right answer, wrong question!
Thanks for the suggestion, it works really well. Unfortunately I posted the question when I was half asleep, so I apologies for the fact that I will now have to ask you a revised question. I actually need to be able to dismount the the truck and move around. I control the truck with a joypad with the head ori of the view set to mouselook and envisage controlling the view in the same way when I dismount. Here's the joypad script I'm using to drive the FLT:
Code:
#Use joystick to control FLT navigation def UpdateMovement(): #Get the joystick position x,y,z = joy.getPosition() #Get the twist of the joystick twist = joy.getTwist() #Using the z value off the twist control for up and down if abs(y) > 0.3 or abs(y) < -0.3: SetThrottle(-y) if abs(y) <0.3 and abs(y) >-0.3: SetThrottle(0) if abs(twist) > 0.2 or abs(twist) < -0.2: steer(twist*70) steerWheel(-twist*65) elif abs(twist) < 0.2 or abs(twist) > -0.2: steer(0) steerWheel(0) #UpdateJoystick every frame vizact.ontimer(viz.FASTEST_EXPIRATION,UpdateMovement) Thanks for your patience, Nige |
#4
|
|||
|
|||
I'm not exactly clear on what you are trying to accomplish. It seems like you just need to disable the UpdateMovement function while you are dismounted from the truck, and enable it when you are mounted. Let me know if I misunderstood your question.
|
#5
|
|||
|
|||
Hi fashizzo,
Yes, you are quite right, I need to disable the UpdateFLTMovement() function whilst dismounted from the truck. However, I now have 2 functions, one for moving the truck, one for moving the view, but am unable (in my sleep deprived state ) to switch toggle between them. I have tried all manner of enable and disable combinations - but to no avail. I feel that (once again) I am missing something really simple All help gratefully received |
#6
|
|||
|
|||
RE:Ignore me!
Please disregard the last post - I have had some sleep and my brain has started working again
I just put the two functions in a timer and just call or kill whichever one I want! Cheers Nige |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
General question and question regarding arrays | dan12345 | Vizard | 1 | 01-15-2008 10:15 AM |
Stereo Overlap question | JMOwens | Vizard | 2 | 01-08-2008 08:54 AM |
viztask question | asimbh | Vizard | 1 | 11-20-2007 09:12 AM |
Another color question | mjabon | Vizard | 4 | 07-31-2007 03:04 PM |
Basic Joystick Navigation Question | Plasma | Vizard | 2 | 01-29-2004 07:08 PM |