WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Help with the slider (

BSUGeek 03-16-2015 10:36 AM

Help with the slider
I'm having trouble using the slider to change the speed of my viewpoints movement. While i'm moving i want to be able to use the slider to increase or decrease my movement speed. How can i do that?

shivanangel 03-16-2015 10:47 AM

What are you using to move around?
Just grab the sliders value

pos = slider.get()

Multiply by some movement speed to make the value larger than 0 to 1

Set the speed equal to the newly calculated rate/force/speed/etc.. you are using to move around the environment with.

BSUGeek 03-16-2015 11:04 AM

Here's the code i have so far. I'm not sure how i should have my move_speed increase and decrease with the slider



sliderPanel = vizinfo.InfoPanel(text=None, icon=False)
slider = sliderPanel.addLabelItem('Speed', viz.addSlider())

def mySlider(pos):


def updatecar():

    #move view forward and backward
    if viz.key.isDown(viz.KEY_DOWN):
    if viz.key.isDown(viz.KEY_UP):

        #rotate body of view left and right
    if viz.key.isDown(viz.KEY_RIGHT):
    elif viz.key.isDown(viz.KEY_LEFT):

shivanangel 03-16-2015 11:09 AM

For the easy way out, you can read the state of the slider in the updateCar method.

If you multiply the movement speed by the slider value, it will allow you to scale between 0 and your max speed, which is 60 in this case.

view.move([0, 0, MOVE_SPEED*slider.get()*viz.elapsed()], viz.BODY_ORI)

Do this for each movement call you make. You are now scaling the speed of the car by the amount of time since the last update and the value of the slider.

BSUGeek 03-16-2015 11:15 AM

that worked great! thanks alot for your help! :D

BSUGeek 03-16-2015 11:19 AM

Is there a way to show your speed on the screen as it's changing?

shivanangel 03-16-2015 11:23 AM

Create a text object on the screen.
Look up text node basics in the Vizard help file.
Grab the value and set the text equal to it.

All times are GMT -7. The time now is 07:40 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC