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