Flying vehicle confusion?
by Gonzo T. Clown · in Torque Game Engine · 08/30/2004 (7:26 am) · 6 replies
Has anybody YET got a flying vehicle to hover at the createHoverHeight or hoverHeight settings?
I'm so sick of trying to figure out why no matter what I set my settings at my vehicle flops around on the ground like a fish out of water.
I inserted this line into the FlyingVehicle::updateForces() function....
Con::printf("Height is: %d for vehicle\n", h);
just behind this line....
F32 h = getHeight();
and all I get from it is jibberish like...
Height is: 1288490189 for vehicle
Height is: -1503238554 for vehicle
Height is: -1073741824 for vehicle
Height is: 0 for vehicle
Height is: 429496730 for vehicle
Height is: -2147483648 for vehicle
Height is: -858993459 for vehicle
Height is: -429496730 for vehicle
Height is: 0 for vehicle
Height is: -1288490189 for vehicle
Height is: -2147483648 for vehicle
etc... etc... And thats all from the same log in just a few seconds. Obviously the vehicle is not moving up and down that fast and this function here is just plain screwed for some reason.
Please for the love of god can anyone fix this thing once and for all or tell me what I am doing wrong?
I'm so sick of trying to figure out why no matter what I set my settings at my vehicle flops around on the ground like a fish out of water.
I inserted this line into the FlyingVehicle::updateForces() function....
Con::printf("Height is: %d for vehicle\n", h);
just behind this line....
F32 h = getHeight();
and all I get from it is jibberish like...
Height is: 1288490189 for vehicle
Height is: -1503238554 for vehicle
Height is: -1073741824 for vehicle
Height is: 0 for vehicle
Height is: 429496730 for vehicle
Height is: -2147483648 for vehicle
Height is: -858993459 for vehicle
Height is: -429496730 for vehicle
Height is: 0 for vehicle
Height is: -1288490189 for vehicle
Height is: -2147483648 for vehicle
etc... etc... And thats all from the same log in just a few seconds. Obviously the vehicle is not moving up and down that fast and this function here is just plain screwed for some reason.
F32 FlyingVehicle::getHeight()
{
Point3F sp,ep;
RayInfo collision;
F32 height = (createHeightOn) ? mDataBlock->createHoverHeight : mDataBlock->hoverHeight;
F32 r = 10 + height;
getTransform().getColumn(3, &sp);
ep.x = sp.x;
ep.y = sp.y;
ep.z = sp.z - r;
disableCollision();
if (!mContainer->castRay(sp,ep,0,&collision))
collision.t = 1;
enableCollision();
return (r * collision.t - height) / 10;
}Please for the love of god can anyone fix this thing once and for all or tell me what I am doing wrong?
About the author
#2
For instance i *think* (really not sure here) there was some daft thing about it not checking to hover over terrain types or something.
I'm really not sure tho, but I do remember something along those lines.
08/30/2004 (2:51 pm)
I seem to remember a while ago about something to do with the checks on what it should be hovering over.For instance i *think* (really not sure here) there was some daft thing about it not checking to hover over terrain types or something.
I'm really not sure tho, but I do remember something along those lines.
#3
08/30/2004 (3:09 pm)
Use a non-null collision mask at getHeight() function as in this snippet:U32 mask = TerrainObjectType |
InteriorObjectType |
StaticShapeObjectType |
PlayerObjectType |
VehicleObjectType;
disableCollision();
if (!mContainer->castRay(sp,ep,mask,&collision))
collision.t = 1;
#4
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 840429792 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 840230644 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 840035477 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 839844210 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 839656777 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137624941 for vehicle
Height is: 1243908 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137624941 for vehicle
Height is: 6 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137624941 for vehicle
08/30/2004 (3:12 pm)
Height is: 840633019 for vehiclegetHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 840429792 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 840230644 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 840035477 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 839844210 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137625037 for vehicle
Height is: 839656777 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137624941 for vehicle
Height is: 1243908 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137624941 for vehicle
Height is: 6 for vehicle
getHeight is: 0 for vehicle
R is: 0 for vehicle
sp is: 1137624941 for vehicle
#5
You mean the h = getHeight(); is first or the Con::printf() is first? If the printf is first, then the problem is that h is being set *after* its printed, so when its printed its just gibberish. It would certainly explain the large values you are seeing.
T.
08/30/2004 (3:24 pm)
Quote:
Con::printf("Height is: %d for vehicle\n", h);
just behind this line....
F32 h = getHeight();
You mean the h = getHeight(); is first or the Con::printf() is first? If the printf is first, then the problem is that h is being set *after* its printed, so when its printed its just gibberish. It would certainly explain the large values you are seeing.
T.
#6
F32 vf = -sFlyingVehicleGravity * mRigid.mass * mGravityMod;
F32 h = getHeight();
Con::printf("Height is: %d for vehicle\n", h);
08/30/2004 (8:20 pm)
// Hovering JetF32 vf = -sFlyingVehicleGravity * mRigid.mass * mGravityMod;
F32 h = getHeight();
Con::printf("Height is: %d for vehicle\n", h);
Torque Owner Bruno Grieco