SteerVehicle
#2
Steering should already work now, as it is. the cEntity::SteerVehicle is called when the packet is received, and it adds speed to the vehicle entity (any vehicle entity).

If you think you need special steering for entities, create a new virtual function in cEntity, let's call it OnSteered(cEntity & a_Driver, float a_Forward, float a_Sideways) and make it do what SteerVehicle does to m_AttachedTo. Then you can override it in any cEntity's descendant to provide specific steering.

void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
{
	if (m_AttachedTo == NULL)
	{
		return;
	}
	m_AttachedTo->OnSteered(*this, a_Forward, a_Sideways);
}

void cEntity::OnSteered(cEntity & a_Driver, float a_Forward, float a_Sideways)
{
	if ((a_Forward != 0) || (a_Sideways != 0))
	{
		Vector3d LookVector = a_Driver.GetLookVector();
		double AddSpeedX = LookVector.x * a_Forward + LookVector.z * a_Sideways;
		double AddSpeedZ = LookVector.z * a_Forward - LookVector.x * a_Sideways;
		AddSpeed(AddSpeedX, 0, AddSpeedZ);
	}
}
Reply
Thanks given by:


Messages In This Thread
SteerVehicle - by tigerw - 09-09-2013, 02:01 AM
RE: SteerVehicle - by xoft - 09-09-2013, 02:45 AM
RE: SteerVehicle - by tigerw - 09-09-2013, 02:51 AM
RE: SteerVehicle - by xoft - 09-09-2013, 06:09 AM



Users browsing this thread: 1 Guest(s)