How to use "CreatePivot"?

Blitz3D Forums/Blitz3D Beginners Area/How to use "CreatePivot"?

Happy Sammy(Posted 2005) [#1]
Hi all,

Why and when to use "CreatePivot"?
What is the difference to program with/without "CreatePivot"?
Could anyone give some simple examples for illustration?

Thanks in advance.
Sammy


WolRon(Posted 2005) [#2]
Many reasons.
Check out my First Person Shooter example code at my Tutorial site and see how the code sets up a Pivot as the actual player. A pivot works because since it's First-Person, there is no need to have an actual model. No one would see it anyways.

By the way, why would you program without "CreatePivot"?


Beaker(Posted 2005) [#3]
http://www.blitzbasic.com/Community/posts.php?topic=51740


sswift(Posted 2005) [#4]
You can use pivots for all sorts of useful things.

Let's say that you want a car to drive around in a circle. Place a pivot in the center of the circle. Then make the car a child of the pivot, and move it out to the edge of the circle pointing in the direction you want it to travel.

Then all you need to do is rotate the pivot, and the car will orbit around it, like a moon or a planet.

Pivots can also be useful when calculating vectors for doing physics and moving things in your world. But this is too advanced for me to explain to you right now. :-)

(A vector is like an arrow with a certain length pointing in some direction. The length of the arrow might specify the speed at which the object is moving, and the direction the arrow points specfies the direction it moves in.)


PowerPC603(Posted 2005) [#5]
You can also use pivots as waypoints for your units.
Let's say you create a game like CnC or Red Alert or something similar.
Then you could add routines to let your units patrol a certain area.
To create a patrol-route, you place pivots around the battlefield and you let your units:
1) move to waypoint (pivot) no 1.
2) when they reach it, select the next waypoint for that specific patrol-route
3) point your units to it
4) let them move towards it
5) goto step 2.

You can also use a pivot for plotting a smooth course for a spaceship.
Create a pivot and point your spaceship towards it.
Move the pivot every frame to plot a course and let your spaceship point towards it (also every frame).
This will be smoother than letting your spaceship move towards the pivot and when it reaches it, put the pivot somewhere else and point your ship towards that again.

When taking big steps between waypoints, moving towards it and only move the pivot when your ship reaches it, would result in sudden course-changes that won't look natural (sudden turns of your ship).
There's a demo that shows this, but I cannot find it on my pc.

You can also use pivots to attach lots of models together.
When moving only the pivot, all children of that pivot (all those models) will move along with it.

That way, you could create a big crane that can lift stuff.
You make the magnet a child of that pivot, and any other stuff that's below the magnet.
When moving the pivot up and down, the magnet and all things under the magnet move up and down too, creating the illusion that the magnet really works.


octothorpe(Posted 2005) [#6]
I think it pretty much boils down to: avoiding math.

Let's say you have a turn-based strategy game and you want to let the player pan around the map, spin the map around, and tilt the angle he's viewing it at. This could all be solved by a bunch of potentially ugly trig - or by parenting the camera to a pivot, pointing the camera at it, and moving/rotating the pivot.


Happy Sammy(Posted 2005) [#7]
Thanks a lot.
Now, I understand "CreatePivot" more.

Sammy


jfk EO-11110(Posted 2005) [#8]
I want to explain it too :)

A pivot is a mesh without triangles. It's a point in 3D space that can be used like a mesh, only it's invisibble since there is no shape, and its size is also zero.

Sometimes you need it as a helper. As explained earlier in this thread.


Happy Sammy(Posted 2005) [#9]
Thanks a lot
Sammy