How to Change the Player in SimpleChar to be a Tank (or other Land Vehicle)
From C4 Engine Wiki
Here are some very simple changes to SimpleChar.cpp which will allow you to replace the model in that example with a vehicle model (say for example a simple tank). How to do this is probably obvious to many, but to some it may not be, especially at the beginning. Basically, we just stop the soldier animations which would otherwise cause your vehicle to move like the soldier does.
Note that this was last tested with Build 146, but should also work on older builds.
First, register your vehicle model in Game::Game()
soldierEntityReg(kEntitySoldier, "model/<YourModelName>", kEntityPrecache, kControllerSoldier),
Then in SoldierController::Preprocess(void), just comment out these lines:
//Entity *soldier = GetTargetNode(); //frameAnimator = new FrameAnimator(soldier); //soldier->SetRootAnimator(frameAnimator);
Then in SoldierController::Move(void), comment out this line:
//if (motion != soldierMotion) SetMotion(motion);In ChaseCamera::Move(void), you can adjust the height and trail distance of the camera, by adjusting the values in these two lines:
Point3D p1(position.x, position.y, position.z + 3.5F);//was 1.5F, now (say) 3.5F, so a bit higher up Point3D p2 = p1 - view * 8.0F;//was 4.0F, now (say) 8.0F, a bit further back
After you compile that, to test it, just change the application name in C:\Users\<yourname>\AppData\Roaming\C4 Engine\variables.cfg file to SimpleChar
$applicName = "SimpleChar";
Then start up C4, hit Escape and then tilde (~) to get the Tools menu. Choose Open World and go to Tutorial then World and choose a relatively simple world like Water.wld. Then choose World, then Save and Play World. Hit Escape twice and start driving your tank around.
Note that the model you use will need to have collision settings like those the player (Soldier) in SimpleCharacter:
--Jimbobjames 06 February 2008

