Game Development Community

Changing players

by Quentin Headen · in Game Design and Creative Issues · 10/28/2006 (3:25 pm) · 11 replies

Here I am again. I want to know how to change player shapes when I am in a level. For example, lets just say I want to change my player from a person to a vehicle, or to another person. I am making a racing game, but I want different types of cars in the game. How can I do this?



Thanks

About the author

Just your average programmer who tries to finish the projects he starts. :) I am currently focused on creating games with Torque engines. My website is http://phaseshiftsoftware.com


#1
10/28/2006 (9:37 pm)
I guess no one is responding to this thread.
#2
10/28/2006 (9:47 pm)
Way to be patient on a saturday evening there, quentin.

on the server-side, just use setDatablock() on the player with the datablock of the new shape.

eg

function ServerCmdUseOtherShape(%client)
{
   %client.player.setDatablock(theOtherShapeDataBlock);
}
#3
10/29/2006 (4:56 pm)
I tryed this with the starter.fps kit. I tryed to change the orc to one of my cars. I tryed to do this to see how the code you provided me works. When I do try it, the console says,"Cannot find object". What am I doing wrong. I have the car data in the starter.fps folder, and my program points to the right directory, but why is it saying that.
#4
10/30/2006 (9:23 am)
Things to check:

Make sure the car data is being loaded.
Make sure the models are there.
Check that you're using the serverCmd / Cmdtoserver correctly

but I don't know if changing the datablock will have the on-the-fly effect of changing the model. Has anyone tried this out? There are however a lot of resources for altering and dynamically switching models around.

Lastly,switching from the ork to a car is more than just switching datablocks. The control, damage, camera, and a bunch of other systems are different, just look at the differences between the FPS and Racing starters. Depending on what you're doing I'll propose two other solutions. If you're making a racing game start out with starter.racing and edit the car datablock/s to create different cars, then work on some way of choosing your car. If you're making a game where you run around and can get in cars then try getting the car object (plus all its component parts like the suspension and all that) into the starter.fps, when somone gets in a car you can mount the player model in/on it, set the control object to the car and switch the controls system.

This is a resonably common situation in games, so I imagine that if you do a good search through the resources you'll find things to help you out in both of these senarios.

Hope that helped...
Davidovich
#5
10/30/2006 (9:32 am)
Quote:I don't know if changing the datablock will have the on-the-fly effect of changing the model. Has anyone tried this out?
i haven't tried Player <-> Vehicle, but it definitely works Player <-> Player.
#6
10/30/2006 (10:36 am)
I am making a racing game.
#7
10/30/2006 (10:46 am)
I just put in the code, but it still won't work. Here is the code:


function change(%client)
{
%client.player.setDatablock(DefaultCar);
}



I just tryed this code with the racing game. I still get the same message I showed everyone in the last post. I just don't know what to do. I need to be able to do this because in my racing game, i'm going to have multiple cars. If you notice, I changed the car from Box car to Default car. I did this to see if I can change my car the the default buggy that they use in the game.
#8
10/30/2006 (4:37 pm)
I'm not any sort of expert, but i'd guess that because you're not using the cmdtoserver function the client variable isn't being put into the function correctly.

I would try putting
function ServerCmdUseOtherShape(%client)
{
   %client.player.setDatablock(DefaultCar);
}
on the server side and then
function changeCar()
{
commandtoserver('UseOtherShape');
}
on the client side. This should pass the client properly.You (theoretically) will then be able to just call changeCar() and it will switch, you could even bind it to a key for easier switching. If this doesn't work try putting some echo calls in so you can see if %client and %client.player are all set correctly.

Good luck. And as I said I'm no expert, so no one abuse me If I'm totally wrong!
#9
11/24/2006 (1:29 pm)
I'm not sure if I should ask in this thread, but I have a somewhat similar issue:
I've got two missions in a game, the first is FPS-style and the player walks around to reach the GarageGames buggy (Static Shape, not a Vehicle); at that point, I've got some GUIs explaining the next level, then I load a Racing mission and appropriate obstacle shapes. The vehicle is set as the client's player, but cannot be controlled at all. I pasted the appropriate functions from the racing game.cs into the first mission's game, and everything works just the same as when these two missions were in completely separate folders, up until "Go". I've tried executing the config.cs and default.bind.cs for Racing at the beginning of the whole thing, as well as immediately before loading the second mission. What am I doing wrong? Is this the totally wrong approach?
#10
11/30/2006 (10:38 am)
I figured it out (which opened up another problem); it was just a matter of specifying the right PlayGui.gui within functions in its corresponding .cs file (I made two versions since the examples use different GUIs).
#11
12/01/2006 (6:06 pm)
Why is this posted in the game design forum?