mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
take flight floor and ceiling into account for yaw too
ditch roll compensation as it was causing more problems than it was solving
This commit is contained in:
parent
8fa132707d
commit
b643aa41a2
2 changed files with 11 additions and 17 deletions
|
|
@ -718,10 +718,10 @@ void AIFlyingVehicleControllerData::initPersistFields()
|
||||||
docsURL;
|
docsURL;
|
||||||
addGroup("AI");
|
addGroup("AI");
|
||||||
|
|
||||||
addFieldV("FlightFloor", TypeRangedF32, Offset(mFlightFloor, AIFlyingVehicleControllerData), &CommonValidators::PositiveFloat,
|
addFieldV("FlightFloor", TypeRangedF32, Offset(mFlightFloor, AIFlyingVehicleControllerData), &CommonValidators::F32Range,
|
||||||
"@brief Max height we can target.");
|
"@brief Min height we can target.");
|
||||||
|
|
||||||
addFieldV("FlightCeiling", TypeRangedF32, Offset(mFlightCeiling, AIFlyingVehicleControllerData), &CommonValidators::PositiveFloat,
|
addFieldV("FlightCeiling", TypeRangedF32, Offset(mFlightCeiling, AIFlyingVehicleControllerData), &CommonValidators::F32Range,
|
||||||
"@brief Max height we can target.");
|
"@brief Max height we can target.");
|
||||||
|
|
||||||
endGroup("AI");
|
endGroup("AI");
|
||||||
|
|
@ -743,15 +743,15 @@ void AIFlyingVehicleControllerData::resolveYaw(AIController* obj, Point3F locati
|
||||||
|
|
||||||
Point3F right = fvo->getTransform().getRightVector();
|
Point3F right = fvo->getTransform().getRightVector();
|
||||||
right.normalize();
|
right.normalize();
|
||||||
Point3F aimLoc = obj->mMovement.mAimLocation;
|
|
||||||
|
|
||||||
// Get the Target to AI vector and normalize it.
|
// Get the Target to AI vector and normalize it.
|
||||||
|
Point3F aimLoc = obj->mMovement.mAimLocation;
|
||||||
|
aimLoc.z = mClampF(aimLoc.z, mFlightFloor, mFlightCeiling);
|
||||||
Point3F toTarg = (location + fvo->getVelocity() * TickSec) - aimLoc;
|
Point3F toTarg = (location + fvo->getVelocity() * TickSec) - aimLoc;
|
||||||
toTarg.normalize();
|
toTarg.normalize();
|
||||||
|
|
||||||
F32 dotYaw = -mDot(right, toTarg);
|
|
||||||
movePtr->yaw = 0;
|
movePtr->yaw = 0;
|
||||||
|
F32 dotYaw = -mDot(right, toTarg);
|
||||||
if (mFabs(dotYaw) > 0.05f)
|
if (mFabs(dotYaw) > 0.05f)
|
||||||
movePtr->yaw = dotYaw;
|
movePtr->yaw = dotYaw;
|
||||||
};
|
};
|
||||||
|
|
@ -770,25 +770,18 @@ void AIFlyingVehicleControllerData::resolvePitch(AIController* obj, Point3F loca
|
||||||
|
|
||||||
Point3F up = fvo->getTransform().getUpVector();
|
Point3F up = fvo->getTransform().getUpVector();
|
||||||
up.normalize();
|
up.normalize();
|
||||||
Point3F aimLoc = obj->mMovement.mAimLocation;
|
|
||||||
aimLoc.z = mClampF(aimLoc.z, mFlightFloor, mFlightCeiling);
|
|
||||||
|
|
||||||
// Get the Target to AI vector and normalize it.
|
// Get the Target to AI vector and normalize it.
|
||||||
|
Point3F aimLoc = obj->mMovement.mAimLocation;
|
||||||
|
aimLoc.z = mClampF(aimLoc.z, mFlightFloor, mFlightCeiling);
|
||||||
Point3F toTarg = (location + fvo->getVelocity() * TickSec) - aimLoc;
|
Point3F toTarg = (location + fvo->getVelocity() * TickSec) - aimLoc;
|
||||||
toTarg.normalize();
|
toTarg.normalize();
|
||||||
F32 lastPitch = fvo->getSteering().y;
|
|
||||||
|
|
||||||
movePtr->pitch = 0.0f;
|
movePtr->pitch = 0.0f;
|
||||||
F32 dotPitch = mDot(up, toTarg);
|
F32 dotPitch = mDot(up, toTarg);
|
||||||
|
|
||||||
FlyingVehicleData* db = static_cast<FlyingVehicleData*>(fvo->getDataBlock());
|
|
||||||
|
|
||||||
F32 rollAmt = mFabs(fvo->getThrottle()* movePtr->yaw / (db->steeringRollForce+1.0));
|
|
||||||
dotPitch *= 1.0-(mClampF(rollAmt, 0.0,1.0)); // reduce pitch by how much we're rolling
|
|
||||||
dotPitch *= M_2PI_F;
|
|
||||||
|
|
||||||
if (mFabs(dotPitch) > 0.05f)
|
if (mFabs(dotPitch) > 0.05f)
|
||||||
movePtr->pitch = dotPitch;
|
movePtr->pitch = dotPitch * M_2PI_F;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,5 +183,6 @@ datablock AIWheeledVehicleControllerData( aiCarControl )
|
||||||
datablock AIFlyingVehicleControllerData( aiPlaneControl )
|
datablock AIFlyingVehicleControllerData( aiPlaneControl )
|
||||||
{
|
{
|
||||||
moveTolerance = 2.0; followTolerance = 5.0; mAttackRadius = 10.0;
|
moveTolerance = 2.0; followTolerance = 5.0; mAttackRadius = 10.0;
|
||||||
|
FlightFloor = 15; FlightCeiling = 150;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue