Align to Vector problem

Blitz3D Forums/Blitz3D Beginners Area/Align to Vector problem

Gazza69(Posted 2013) [#1]
Hi all, consider this scenario:

I've made a simple jet using primitives, cube is the body, which is parented to delta shape wings, which in turn is parented to a pivot.
I have ordered the jet so that it is oriented in the z axis direction.
The jet is a type, with relevant fields to control it.
Using :

MoveEntity jetpivot, 0,0,speed

gives me what I want, it moves forward. I can yaw and roll the jet by using:

RotateEntity jetpivot, 0, jetyaw, 0 etc.

I then have a distant point (another pivot) that I want to move the jet towards.

I get the entity x, y and z coords of the distant pivot, subtract the entity x y and z coords of the jetpivot giving new_x, new_y and new_z, to then use:

AligntoVector jetpivot, new_x,new_y,new_z,z, 0.3

This should point the jet correctly at the pivot point, but it doesn't ; it inverts the jet, rotates it 90 degrees about the z axis and then the jet proceeds towards the pivot point, but in a crab like fashion (albeit not very gracefully)

Any ideas as to what I am doing wrong ?

Gazza


Midimaster(Posted 2013) [#2]
what about

PointEntity JetPivot, DestiPivot

?


GfK(Posted 2013) [#3]
Yep, PointEntity is what you need. Although if you want to turn your cube-plane gradually towards a specific point, then use DeltaYaw() and/or DeltaPitch() combined with TurnEntity().

[edit] Oh, one more thing - don't know how you modeled the plane, but software sometimes uses different axes. Most are Y-Up, but not all - if they're Z-Up, then you might have problems with objects not being oriented correctly.

Last edited 2013


Floyd(Posted 2013) [#4]
AligntoVector jetpivot, new_x , new_y , new_z , z , 0.3

The next to last parameter (currently z) is supposed to be a number indicating which axis to align. 3 is the magic number for z-axis.

Last edited 2013


Gazza69(Posted 2013) [#5]
Thanks guys, and yes Floyd, I did find my little bug there.
It still puzzles me a bit though as to why this is occurring. I will play around a bit more with the other suggestions, I', thinking it must be a bit to do with my model.
One last question on this: If my cube plane (with child add ons) is parented to another pivot and this pivot is the parent for the entire hierachy, well then, it should follow that if my cube plane is flying along dead flat (ie no roll), then I call the aligntoentity command along the z axis, this should not affect the roll at all - it should only affect the pitch and yaw ? Somehow I'm getting roll. I'II have to tidy up the code a bit and post it, theres a bit of spaghetti in the ATM.


Gazza69(Posted 2013) [#6]
I've solved this problem guys, I'm now using some 3ds models and they are behaving themselves beautifully. As graceful as a couple of F-22 Raptors. Now I've just got to make them do something warlike....