SteerVehicle
#1
¡Buenos dias!

xoft recently implemented SteerVehicle, and I have been working on it to get Minecart and Boat propulsion working.

However.

I cannot get it to override in Minecart.cpp or Boat.cpp, it tells me that there is no base constructor. Therefore, I have had to put it in Entity.cpp, which I am certain is disagreeable to xoft.

What do I do here?

Thanks.
Reply
Thanks given by:
#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:
#3
Thanks!

Special steering? Of course! One does not simply steer one's minecart off the rails, as the current code allows one to do!Tongue
Reply
Thanks given by:
#4
Well, you should focus more about the minecart's position (it's in fact 1 block above the rail, although the client shows it correct), and the fact that the minecarts don't snap onto the rails. If they did, steering would work even in its current state.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)