Moving an entity from point x,y,z to x1,y1,z1

Blitz3D Forums/Blitz3D Programming/Moving an entity from point x,y,z to x1,y1,z1

paultheaxeman(Posted 2005) [#1]
I'm sure the code to this is available somewhere but the search function is disabled for me at the moment.
Can someone show me some code to move an entity from point x,y,z to another x,y,z point smoothly. The code is probably simple but I just can't get my head round it.
Thanks


KuRiX(Posted 2005) [#2]
two ways of doing this:

1) Interpolating.

Make a 3d line that passes through both points and translate the entity over the line.

2) Rotating and moving.

pointentity entity1,entity2(pivot at x1,y1,z1).
moveentity entity1,0,0,step

Cheers! and Good Luck!


Bot Builder(Posted 2005) [#3]
make a 3d line? o.0

Anyway, the way I would do it is just have an entity home in on the point - the position it is at is the start point. Although this isn't very fast, the other resuable way would probably involve types.

Function MoveTowards(Ent,X#,Y#,Z#,S#=1)
 L#=1/Sqr(X*X+Y*Y+Z*Z)
 TranslateEntity Ent, X*L*S, Y*L*S, Z*L*S
End Function
Just guessing on this - punched code into browser.


jfk EO-11110(Posted 2005) [#4]
you can also position a dummy pivot at xyz2, then store the objects rotation by storing entityPitch, EntityYaw and EntityRoll, then point the object to the pivot and move it one step forward, then re-assign the rotation you just stored to the object. This way all the maths are done by the 3D Engine and you don't have to worry about it.


paultheaxeman(Posted 2005) [#5]
good suggestions here, thanks.


Craig H. Nisbet(Posted 2005) [#6]
Actually there is a spline example in the example code that come with Blitz 3D that does this real well. Even has ease in and ease out caps. Just set the tension for the keyframes to 1.