주 콘텐츠로 건너뛰기

검색

Orientation in flight / 3d space

  • Mm Bogdan & Matt

    Hi,
    the most robust solution is probably to use a bit of vector maths.

    First thing you need is a vector that points along the direction of your aircraft's nose. You can get this by placing a movement sensor on the aircraft, set "Local Space" on, and align the X Direction (the white arrow with X on it) along the aircraft's nose.

    Next thing you want to do is a "Vector Dot Product" with a vector that represents the direction of gravity. This will essentially get you a number that is 1 when the nose points directly down, -1 when the nose points directly up and 0 when the nose is level with the horizon. Luckily the dot product in this special case is simply the Y component of the aircraft nose vector multiplied by -1. So you just need to add a splitter to the X Direction output of the movement sensor, take the Y component from the splitter and multiply it by -1. Obviously you can forgo the multiply by -1 and just take into account the result will be inverted.

    Hope that helps
    Matt

  • IAMDOODLEBUG

    Hi Matt

    Thanks very much for the prompt reply! I thought it had cracked it, as upon first testing it works exactly as intended. However, as soon as you alter the course from straight ahead, the numbers go crazy exactly the same as my attempt with the angle sensor. If you turn 180 degrees, the numbers are flipped, if you turn anywhere in between I cant figure out the pattern but they go crazy. Anything other than straight on and even the roll of the aircraft affects the number even if the X direction remains the same.

    Anything you can do to help would be massively appreciated!

  • IAMDOODLEBUG

    I've messed around some more to figure out what's going on - the axis are staying fixed to the world even with local space turned on. I've tried all three axis and get the same result.

    In the case of X pointing straight ahead, initially the pitch rotates about the Z axis and the split 3 value from X starts at 1 and changes between -1 and 1, as well as the split B value from Y which starts from 0. If you rotate the heading by 90 degrees, the split B value from X starts at -1 and changes between -1 and 1, as well as the split 3 value from Y which starts at 0.

    Basically, none of the axis follow the plane, so the outputs change depending on which direction the aircraft is facing.

  • Mm Bogdan & Matt

    Hi, if you're not seeing the axes follow the plane then it sounds like the movement sensor is not attached to the thing you think it is. Try placing it directly on a part of the aircraft model rather than on a group. Remember that if you make a model or group moveable (or place a mover/rotator on them) then they will no longer move with the parent group.

  • IAMDOODLEBUG

    Will try this later thanks very much sir! Fingers crossed :-)

  • IAMDOODLEBUG

    No luck I'm afraid... :-( to make sure I wasn't doing anything wrong I started a new scene, created a single block, added the movement sensor directly to it and then fed the outputs to a microchip with the splitters. Exactly the same problem with different values changing depending on the direction the block is facing. I'm very stuck!

  • IAMDOODLEBUG

    I should add, the axis themselves from the movement sensor follow the object but the x y and z values switch around depending on the direction. It's like the x y and z values are tied the the world, so whichever axis from the sensor aligns, this is the one which changes the dot vector product value.

  • IAMDOODLEBUG

    I'm at a loss :-(

  • IAMDOODLEBUG

    SUCCESS!!!!! I cant tell you how happy I am! I completely overlooked the greyed out outputs on the splitters. I had assumed only the two lit ones did anything but upon randomly linking B to a calculator the magic happened :-) thanks for your help Matt!

댓글을 남기려면 로그인하세요.