示例#1
0
USVec3D SeekSteering::GetSteering( Character* character, const USVec3D& targetPos )
{
	USVec3D newDir = targetPos - character->GetLoc();
	
	newDir.Norm();
	newDir *= character->GetMaxVel();

	USVec3D speed = newDir - character->GetLinearVelocity();
	speed.Norm();

	return speed * character->GetMaxAcc();
}
示例#2
0
USVec3D SeekSteering::GetSteeringArrive( Character* character, const USVec3D& targetPos )
{
	USVec3D newDir = targetPos - character->GetLoc();
	float radius =   character->GetDstRadius();
	float distance = newDir.Length();

	newDir.Norm();

	if( distance > radius )	newDir *= character->GetMaxVel();
	else					newDir *= character->GetMaxVel() * ( distance / radius );
	

	USVec3D speed = newDir - character->GetLinearVelocity();
	speed.Norm();

	return speed * character->GetMaxAcc();

}