Car instead of Player in starter.fps
by Dustin Mullen · in Technical Issues · 06/09/2008 (12:18 pm) · 27 replies
How would I use a car (the buggy) instead of a player for the starter.fps?
I copied the car.cs (put in server), the car shapes(put it shapes), into my starter.fps.
I commented out player.cs in my game.cs and put in car.cs.
The game froze when I did that.
I then tried just attributing the playerbody() in player.cs to my car object. That somewhat worked, but I don't have wheels and the car just slides around.
Anyone know the proper way to do this?
I copied the car.cs (put in server), the car shapes(put it shapes), into my starter.fps.
I commented out player.cs in my game.cs and put in car.cs.
The game froze when I did that.
I then tried just attributing the playerbody() in player.cs to my car object. That somewhat worked, but I don't have wheels and the car just slides around.
Anyone know the proper way to do this?
#2
06/09/2008 (4:00 pm)
Agree'd it would also be proven to be a lot more efficient.
#3
@Dustin I can help you with that, I've done it for my project but not with a car.
email me and I can rewrite the procedure for you.
I'll return here and edit this later.
06/09/2008 (4:32 pm)
*sigh.. Just posted the method for Dustin and the post lagged out.@Dustin I can help you with that, I've done it for my project but not with a car.
email me and I can rewrite the procedure for you.
I'll return here and edit this later.
#4
06/09/2008 (6:28 pm)
Scott, I have E-mailed you.
#5
Bare with me I'm still new at this.
First we need a Datablock for your car.
For the sake of this thread, lets call the file Mycar.cs
The very least you need is root animation.
Assuming you have just root animation, use the same animation file for the other standard animations. like this:
Finish up your datablock, save the file as Mycar.cs and put the file in:
...\example\starter.fps\data\shapes\mycar\ ( mycar is a new folder you'll make ).
Next you'll need a mycar.cs file thats similar to Player.cs.
You can copy the Player.cs file and rename it to mycar.cs.
Inside your new mycar.cs file you will need to edit the paths.
Example:
When your done editing all your paths then save the file here:
...\example\starter.fps\server\scripts\
Next step is to open game.cs so in this directory:
... \example\starter.fps\server\scripts
find game.cs file and open it.
Around line 56 you'll see this:
change it to look like this:
Save all the files you edited.
Place all of your car animations ( .dsq files ) in the same folder you placed the mycar.cs file.
( ...\example\starter.fps\data\shapes\mycar\ )
Basics are done at this point.
So delete all the .dso files and crank up the Torque.
I realize this procedure has some holes in it like.. not explaining line by line, and what to edit.
It doesn't have pictures and briskly goes through the method.
Note:
engine code changes are necessary when you want your car to act more like a car then a player.. like strafe as example.. never seen a car strafe before.
Google the site, there is a resource for strafe left / strafe right.. it will give you a clue for what to change.
(The heat is unbearable near 100 + humidity and didn't sleep since monday afternoon, but i promised to post this for you.. even if it is sloppy.. I hope it helps )
06/09/2008 (7:12 pm)
Ok Dustin,Bare with me I'm still new at this.
First we need a Datablock for your car.
For the sake of this thread, lets call the file Mycar.cs
datablock TSShapeConstructor (mycardts)
{
baseShape = "./mycar.dts";
sequence0 = "./parked.dsq root";
};The very least you need is root animation.
Assuming you have just root animation, use the same animation file for the other standard animations. like this:
datablock TSShapeConstructor (mycardts)
{
baseShape = "./mycar.dts";
sequence0 = "./parked.dsq root";
sequence1 = "./parked.dsq run";
sequence2 = "./parked.dsq jump";
// etcetera. Otherwise you'll get errors, so you need all the basic animations similar to Player.cs
};Finish up your datablock, save the file as Mycar.cs and put the file in:
...\example\starter.fps\data\shapes\mycar\ ( mycar is a new folder you'll make ).
Next you'll need a mycar.cs file thats similar to Player.cs.
You can copy the Player.cs file and rename it to mycar.cs.
Inside your new mycar.cs file you will need to edit the paths.
Example:
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// H:\Torque\TGEDragon\example\starter.fps\server\scripts\dragon.cs
// Load dts shapes and merge animations
exec("~/data/shapes/mycar/mycar.cs"); // <-- this is your new mycar folder that contains the datablock file.
...
...When your done editing all your paths then save the file here:
...\example\starter.fps\server\scripts\
Next step is to open game.cs so in this directory:
... \example\starter.fps\server\scripts
find game.cs file and open it.
Around line 56 you'll see this:
exec("./player.cs");
exec("./chimneyfire.cs");
exec("./aiPlayer.cs");change it to look like this:
exec("./mycar.cs"); // This makes sure your new mycar.cs file is compiled and executed.
//exec("./player.cs");
exec("./chimneyfire.cs");
exec("./aiPlayer.cs");Save all the files you edited.
Place all of your car animations ( .dsq files ) in the same folder you placed the mycar.cs file.
( ...\example\starter.fps\data\shapes\mycar\ )
Basics are done at this point.
So delete all the .dso files and crank up the Torque.
I realize this procedure has some holes in it like.. not explaining line by line, and what to edit.
It doesn't have pictures and briskly goes through the method.
Note:
engine code changes are necessary when you want your car to act more like a car then a player.. like strafe as example.. never seen a car strafe before.
Google the site, there is a resource for strafe left / strafe right.. it will give you a clue for what to change.
(The heat is unbearable near 100 + humidity and didn't sleep since monday afternoon, but i promised to post this for you.. even if it is sloppy.. I hope it helps )
#6
I'm trying to make a car combat game like twisted metal and this is a step in the right direction.
I didn't have the animation .dsqs for the car model (or any dsqs for that matter), but it still works. Just slides around the map.
If I can figure out how to add wheels to the car and steering ability, I'd be all set.
I'll be adding this to the car combat resource I am trying to make.
06/11/2008 (8:33 am)
I appreciate you helping me out. It's about 100 degrees here also. It's way to hot to sit in a room with no air condition and try to work on this, so I feel you. I'm trying to make a car combat game like twisted metal and this is a step in the right direction.
I didn't have the animation .dsqs for the car model (or any dsqs for that matter), but it still works. Just slides around the map.
If I can figure out how to add wheels to the car and steering ability, I'd be all set.
I'll be adding this to the car combat resource I am trying to make.
#7
06/11/2008 (8:47 am)
My question is, why would you not start using the racing game as your base. It would save you alot of hassles with the current setup, and in your case you would better off looking at the Turret and multiple weapons code imo. Rather then using the FPS kit, which most of it still will transfer over flawlessly as a vehicle. But the controls are already setup in the Racing starter for a Car combat game. I have been considering slapping a turret on to a car and doing a autoassualt-esk car shooter in the future.
#8
I did however manage to get most the car combat game working, however it will not pickup the weapons I have made.
Where would I add the maxinv for the starter.racing?
The weapon did mount when I used the startinv code, just it doesn't register.
I also tried running over it to pick the item up, so I know it must be maxinv problem.
I am aware that the racing damage code is badly broken and I would basically have to write my own. That will probably take awhile, but maybe not if the maxinv code is placed in the right spot.
06/11/2008 (9:15 am)
I have tried that. I used the deathcar resource for weapon mounts. The projectile goes right through the player and does not do any damage. I also tried to damage myself using the radius damage and nothing happens.I did however manage to get most the car combat game working, however it will not pickup the weapons I have made.
Where would I add the maxinv for the starter.racing?
The weapon did mount when I used the startinv code, just it doesn't register.
I also tried running over it to pick the item up, so I know it must be maxinv problem.
I am aware that the racing damage code is badly broken and I would basically have to write my own. That will probably take awhile, but maybe not if the maxinv code is placed in the right spot.
#9
06/11/2008 (9:42 am)
Well, you would simply just transfer over the inventory code, and weapons code. You will need to do some work to get the code to work, and tweak it to your needs. if i understood maxinv code is placed in your car .cs you would need to create a new function for it similar to the player.cs. Basically you just need to recreate the player inventory functions but rename it to work with the car. in the FPS its all player:: and armor:: in the racing kit its all WheeledVehicleData:: i would even go so far as to make sure your player has its own datablock, so you can break out the different cars/ai and such. But thats probably where you largest number of issues are. Once you get all the inventory stuff transfered, you should be able to retweak and and pick it up exactly the same way as FPS.
#10
When I started I always used everyone elses code to understand how to work in Torque.
As I progressed I started trying new things with those scripts.
Then I bought Game Programmers Guide to Torque, and the learning process kicked in high gear.
I'm still new at this but there is a point when letting go of the skirt strings, and trying things on your own is a better lesson thats self taught, and not being carried on the backs of others.
That just the angle I come from.. since anything really worth having, is what you worked to get.
So in that light, hats off to you Dustin.
Sure it will be very rewarding, whether you finish the game or not, your still gaining Valuable knowledge.
P.s. Dustin, if you get the book, your "wheel" issue is part of the lesson.
06/11/2008 (1:31 pm)
I can understand the reason for not using pre-fab scripts.When I started I always used everyone elses code to understand how to work in Torque.
As I progressed I started trying new things with those scripts.
Then I bought Game Programmers Guide to Torque, and the learning process kicked in high gear.
I'm still new at this but there is a point when letting go of the skirt strings, and trying things on your own is a better lesson thats self taught, and not being carried on the backs of others.
That just the angle I come from.. since anything really worth having, is what you worked to get.
So in that light, hats off to you Dustin.
Sure it will be very rewarding, whether you finish the game or not, your still gaining Valuable knowledge.
P.s. Dustin, if you get the book, your "wheel" issue is part of the lesson.
#11
@Scott: I ordered the book. I'll look for the wheel issue. Do you know which page to find it on or what topic it would be under?
06/11/2008 (2:31 pm)
@Edward: I added the inventory, weapon, and item.cs into my starter.racing. I'm not sure what the player inventory functions are and where to find them. I did look over the player.cs, and changed the functions in that to the vehicle and then put them in my car.cs. That didn't work out that well. Can you give me an example of what you mean?@Scott: I ordered the book. I'll look for the wheel issue. Do you know which page to find it on or what topic it would be under?
#12
Wheeled Vehicles.
Edward goes in depth about the vehicle types in TGE
06/11/2008 (2:37 pm)
GPGT page 236.Wheeled Vehicles.
Edward goes in depth about the vehicle types in TGE
#13
06/11/2008 (2:41 pm)
Did you remember to transfer all the other items like the game.cs functions. I should do a mock up, for my own project, but im kinda in the middle of my main project. www.fantascihiddenwar.com What i will do is take some time maybe this weekend or next and setup a quick car combat shooter. :) My first place i would look is the turret controls, and setup a car with a turret, and run inventory through that script. Dont forget to also hook up the default bind for mouse fire and such. Im assuming you are looking for that kind of setup. You can also try to manually add in a alternative inventory setup, there is nothing wrong with doing it yourself as Scott mentioned. But I will take a look at it myself.
#14
Also, one question. In weapon.cs what should I put in the getclassname? I have it set like this:
function Weapon::onPickup(%this, %obj, %shape, %amount)
{
// The parent Item method performs the actual pickup.
// For player's we automatically use the weapon if the
// player does not already have one in hand.
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
serverPlay3D(WeaponPickupSound,%obj.getTransform());
if (%shape.getClassName() $= "car" && <----- This
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}
Scott: Thanks, I'll look for that.
06/11/2008 (3:12 pm)
Edward: I added the game.cs functions. Just copied the one in starter.fps and edited so that instead of all the player. (something) it would say car. (somethng). Yes, that' what I'm looking for.Also, one question. In weapon.cs what should I put in the getclassname? I have it set like this:
function Weapon::onPickup(%this, %obj, %shape, %amount)
{
// The parent Item method performs the actual pickup.
// For player's we automatically use the weapon if the
// player does not already have one in hand.
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
serverPlay3D(WeaponPickupSound,%obj.getTransform());
if (%shape.getClassName() $= "car" && <----- This
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}
Scott: Thanks, I'll look for that.
#15
Now, I just need to make sure I can take damage, but the weapon mounted correctly, shot, and ran out of ammo when I set the player setinv.
I still however can not pick up ammo or weapons.
Now to make a vehicle health bar. I looked into the resource for that, but it didn't compile.
My idea for the healthbarhud for the vehicle:
ShapeBase* control = conn->getControlObject();
if (!control || !(control->getType() & VehicleObjectType))
return;
06/11/2008 (3:24 pm)
I got it working! OMG! What a pain in the @ss this has caused me for weeks!Now, I just need to make sure I can take damage, but the weapon mounted correctly, shot, and ran out of ammo when I set the player setinv.
I still however can not pick up ammo or weapons.
Now to make a vehicle health bar. I looked into the resource for that, but it didn't compile.
My idea for the healthbarhud for the vehicle:
ShapeBase* control = conn->getControlObject();
if (!control || !(control->getType() & VehicleObjectType))
return;
#16
Once you have GPGT, your project will come together much smoother. All the questions your asking now are covered in the book.
06/11/2008 (3:28 pm)
I enjoy reading about your progress Dustin.Once you have GPGT, your project will come together much smoother. All the questions your asking now are covered in the book.
#17



06/11/2008 (3:44 pm)
There are a few Vehicle health tutorials, one of the does work , i know i used it. If you need any advise on vehicles :) ill try to give you some first hand experience, btw all the vehicles you see are in one map and driveable. Including the mech.


#18
Porting the starter.fps over is really easy tho. You just move all the files that have to do with the car over to the starter folder. I posted somewhere here exactly how to do it.
06/11/2008 (4:23 pm)
The only problem with using the starter.racing example as a base is that is doen't work in multiplayer. There was a fix on the forum for it, but I don't recall where.Porting the starter.fps over is really easy tho. You just move all the files that have to do with the car over to the starter folder. I posted somewhere here exactly how to do it.
#19
I did not edit those, but I think those all contain player instead of car.
I'll edit those later today and see what happens.
Scott: The book should be here today or tomorrow, so I'll be able to work better with this soon.
06/12/2008 (9:46 am)
Edward, did you mean the game functions in inventory.h and cc?I did not edit those, but I think those all contain player instead of car.
I'll edit those later today and see what happens.
Scott: The book should be here today or tomorrow, so I'll be able to work better with this soon.
#20
06/12/2008 (11:27 am)
Well, the starter.racing and the starter.fps use the same engine, so at least to start with all the code work should be in the client and server areas. But you will need to simply learn to convert them to work for a car rather then a player.
Torque 3D Owner Edward