mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
more safeties. simplified reverse steering calc
This commit is contained in:
parent
712404c9b4
commit
d36cf31707
4 changed files with 14 additions and 20 deletions
|
|
@ -609,7 +609,6 @@ void AIPlayerControllerData::resolveTriggerState(AIController* obj, Move* movePt
|
|||
}
|
||||
|
||||
IMPLEMENT_CO_DATABLOCK_V1(AIWheeledVehicleControllerData);
|
||||
|
||||
// Build a Triangle .. calculate angle of rotation required to meet target..
|
||||
// man there has to be a better way! >:)
|
||||
F32 AIWheeledVehicleControllerData::getSteeringAngle(AIController* obj, Point3F location)
|
||||
|
|
@ -695,19 +694,13 @@ F32 AIWheeledVehicleControllerData::getSteeringAngle(AIController* obj, Point3F
|
|||
steerState = Left;
|
||||
}
|
||||
|
||||
F32 turnAdjust = myAngle - steering.x;
|
||||
|
||||
F32 throttle = wvo->getThrottle();
|
||||
if (throttle < 0.0f)
|
||||
if (throttle < 0.0f && steerState != Straight)
|
||||
{
|
||||
F32 reverseReduction = 0.25f;
|
||||
if (steerState == Left)
|
||||
steerState = Right;
|
||||
else if (steerState == Right)
|
||||
steerState = Left;
|
||||
turnAdjust *= reverseReduction;
|
||||
myAngle *= reverseReduction;
|
||||
F32 reverseReduction = 0.25;
|
||||
steering.x = steering.x * reverseReduction * throttle;
|
||||
}
|
||||
F32 turnAdjust = myAngle - steering.x;
|
||||
|
||||
F32 steer = 0;
|
||||
switch (steerState)
|
||||
|
|
@ -746,5 +739,4 @@ void AIWheeledVehicleControllerData::resolveYaw(AIController* obj, Point3F locat
|
|||
movePtr->yaw = getSteeringAngle(obj, location);
|
||||
}
|
||||
};
|
||||
void AIWheeledVehicleControllerData::resolveTriggerState(AIController* obj, Move* movePtr) {};
|
||||
#endif //_AICONTROLLER_H_
|
||||
|
|
|
|||
|
|
@ -161,7 +161,8 @@ public:
|
|||
resolveStuckPtr.bind(this, &AIControllerData::resolveStuck);
|
||||
};
|
||||
~AIControllerData() {};
|
||||
|
||||
void packData(BitStream* stream) override {};
|
||||
void unpackData(BitStream* stream) override {};
|
||||
static void initPersistFields();
|
||||
DECLARE_CONOBJECT(AIControllerData);
|
||||
|
||||
|
|
@ -222,11 +223,9 @@ public:
|
|||
AIWheeledVehicleControllerData()
|
||||
{
|
||||
resolveYawPtr.bind(this, &AIWheeledVehicleControllerData::resolveYaw);
|
||||
resolveTriggerStatePtr.bind(this, &AIWheeledVehicleControllerData::resolveTriggerState);
|
||||
}
|
||||
F32 getSteeringAngle(AIController* obj, Point3F location);
|
||||
void resolveYaw(AIController* obj, Point3F location, Move* movePtr);
|
||||
void resolveTriggerState(AIController* obj, Move* movePtr);
|
||||
DECLARE_CONOBJECT(AIWheeledVehicleControllerData);
|
||||
};
|
||||
#endif // TORQUE_NAVIGATION_ENABLED
|
||||
|
|
|
|||
|
|
@ -1744,7 +1744,6 @@ bool Player::onAdd()
|
|||
world );
|
||||
mPhysicsRep->setTransform( getTransform() );
|
||||
}
|
||||
mAIController = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2287,6 +2286,7 @@ DefineEngineMethod(Player, getAIController, AIController*, (), , "")
|
|||
|
||||
bool Player::getAIMove(Move* move)
|
||||
{
|
||||
if (!isServerObject()) return false;
|
||||
if (mAIController)
|
||||
{
|
||||
mAIController->getAIMove(move); //actual result
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ VehicleData::VehicleData()
|
|||
collDamageThresholdVel = 20;
|
||||
collDamageMultiplier = 0.05f;
|
||||
enablePhysicsRep = true;
|
||||
mControlMap = StringTable->EmptyString();
|
||||
mAIControllData = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -505,16 +506,17 @@ void Vehicle::processTick(const Move* move)
|
|||
{
|
||||
PROFILE_SCOPE( Vehicle_ProcessTick );
|
||||
|
||||
ShapeBase::processTick(move);
|
||||
if ( isMounted() )
|
||||
return;
|
||||
|
||||
// If we're not being controlled by a client, let the
|
||||
// AI sub-module get a chance at producing a move.
|
||||
Move aiMove;
|
||||
if (!move && isServerObject() && getAIMove(&aiMove))
|
||||
move = &aiMove;
|
||||
|
||||
ShapeBase::processTick(move);
|
||||
if ( isMounted() )
|
||||
return;
|
||||
|
||||
|
||||
// Warp to catch up to server
|
||||
if (mDelta.warpCount < mDelta.warpTicks)
|
||||
{
|
||||
|
|
@ -1249,6 +1251,7 @@ bool Vehicle::setAIController(SimObjectId controller)
|
|||
|
||||
bool Vehicle::getAIMove(Move* move)
|
||||
{
|
||||
if (!isServerObject()) return false;
|
||||
if (mAIController)
|
||||
{
|
||||
mAIController->getAIMove(move); //actual result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue