Vehicle onNewDataBlock not called, and disapearing tires.
by Richard Terranova · in Torque Game Engine · 10/03/2008 (12:24 pm) · 2 replies
I am making a game where you can change your vehicle while you are playing. Its kind of like how in Tribes you could change your armor class to light, medium, heavy.
I am playing with the Default car in starter.fps.
This works but the tries pop off. Any ideas why this is the case?
I figure I might have to do some coding after I change the datablock. So I add this to my car.cs
But it never gets called.
I walked through the engine in debug mode and the "GameBase::scriptOnNewDataBlock()" in gameBase.cc line 345 is being called. But my script isn't being called.
Any ideas?
What am I missing or not understanding?
Thanks.
I am playing with the Default car in starter.fps.
datablock WheeledVehicleData(OtherCar : DefaultCar)
{
// change some values like sound, speed, health etc..
};
function flipCar(%client, %newCarDatablock)
{
%client.car.setDataBlock(%newCarDatablock);
}This works but the tries pop off. Any ideas why this is the case?
I figure I might have to do some coding after I change the datablock. So I add this to my car.cs
function WheeledVehicleData::onNewDataBlock(%this, %obj)
{
echo("you called?");
}But it never gets called.
I walked through the engine in debug mode and the "GameBase::scriptOnNewDataBlock()" in gameBase.cc line 345 is being called. But my script isn't being called.
Any ideas?
What am I missing or not understanding?
Thanks.
#2
As I recall, some of the wheel initialization calls are different for the server and the client. Some of the work is done in C++ code on the client while the server uses the script. (Again, if I am remembering correctly.)
If something didn't work correctly in the C++ portion on your client, it might result in the wheels not being visible to you (on the client).
Copying script code from the server to the client might end up with extra objects, or cause other problems. I would suggest digging deeper to find the root cause of the problem rather than making a bandaid fix that might cause more trouble later. Another plus is a better understanding of the system for the next time.
10/03/2008 (7:09 pm)
You may need to look into multiplayer vehicle issues deeper. As I recall, some of the wheel initialization calls are different for the server and the client. Some of the work is done in C++ code on the client while the server uses the script. (Again, if I am remembering correctly.)
If something didn't work correctly in the C++ portion on your client, it might result in the wheels not being visible to you (on the client).
Copying script code from the server to the client might end up with extra objects, or cause other problems. I would suggest digging deeper to find the root cause of the problem rather than making a bandaid fix that might cause more trouble later. Another plus is a better understanding of the system for the next time.
Torque Owner Richard Terranova
Default Studio Name
So I just copied the code form "onAdd()" and the wheels appear just fine.
I still would like some help getting the "WheeledVehicleData::onNewDataBlock()" function working. So if anyone has an idea I would appreciated.
Thanks