Vizard 8 » Tutorials & Examples » Viewpoints & windows » Viewpoint collision » Tutorial: Step height
8.0

Tutorial: Step height

If you haven't noticed, there are a set of stairs to the right when you start the script. Try going up the steps.

 

As you can see, when you run into the first step the viewpoint stops. This is because the step is too high. When you are navigating through a world, Vizard will calculate the difference in ground height from one position to the next. If this difference is greater than a certain value, which we call "step size", then Vizard will prevent you from moving any further. In this case the first step is 0.46 meters off of the ground.

 

The default step size is 0.33, so this is why we can't go up the stairs. Vizard allows you to change the step size.

 

Add the following line to the end of your script to set the step size to 0.5, which will allow us to go up the steps now:

viz.MainView.stepSize(0.5)

Run the script again and go up the steps.

 

Notice that things get very jumpy when you go up the steps. This is because Vizard automatically bumps you up to the new height when you reach a step. So you are being bumped up 0.46 meters every time you reach a new step which isn't very smooth.  

 

If you plan on creating a world with steps it is recommended that you either use very small step increments or you just use a ramp.

 

If you need the illusion of steps but want to move smoothly up them then there is a small trick you can perform. Create a flat plane and position it so that it lays on top of the steps, then make the plane transparent. Now when you reach the steps, you will actually be moving across a smooth plane, but you won't actually see it.

 

Add the following code at the end of your script:

quad = viz.addTexQuad()
quad.setScale([2,8.5,1])
quad.setEuler([0,79,0])
quad.setPosition([10,1.2,-1.22])

quad.alpha(0.4)

This creates a flat square and positions it so that it lies on top of the stairs. Initially, it is set to be semi-transparent so we can see where it is and the stairs beneath it.

 

Run your script to see it. Go up the stairs and notice how smooth it is.

To make the flat square fully transparent change the last line of code to be:

quad.alpha(0)

Now you can go up your stairs smoothly while still having them look like stairs.

 

That's it, you should now know how to turn on and use collision detection with Vizard. It is very easy and handy when you want to navigate through a complex environment, and it adds more realism to your world.

Setting up a collision world

Enabling collision detection

Gravity

Step height