find world position of end of cylinder

Lets say my TopPos[0] was 0.5, TopPos[1] was 1.5 and TopPos[2] was 2.5.

And my CylPos[0] was 6.0, CylPos[1] was 10.0 and CylPos[2] was 14.0.
[ TopPos[0]+CylPos[0], TopPos[1]+CylPos[1], TopPos[2]+CylPos[2] ] , is the triplet that expresses the location of the top centre wherever it is.

If you wanted to do something with these locations you could declare them as global variables and pass them to other objects to use as worldPositions or something.

Yo mcguinessdr. You know that if you script: print ( own.worldPosition ) the console will display [ 6.0, 8.5, 12.5 ] or something. If you script: print ( own.worldPosition[0] ) the console will print [ 6.0] and likewise … osition[1] it will get and print [8.5].

So remember I suggested TopPos = own.getAxisVect([ 0.0, 0.0, 1.0*sfZ ]). That means you can get TopPos[0], [1] and [2] and simply add them to the worldPosition tuplets in a script like this:

TrueTopPos = [ own.worldPosition[0] + TopPos[0], own.worldPosition[1] + TopPos[1], …]

Thank you everyone, my script now works perfectly without using any empties, you guys have made my life alot easier.

Here’s a blend. I’m glad I tackled it, it was easier than I thought.


Locate CylinderEnds.blend (523 KB)