View Full Version : Spawning inside a vehicle

03-23-2010, 08:42 AM
Trying to spawn myself as a vehicle for a rally game were currently working on with UDK. elmuerte commented on IRC that I could just spawn as the vehicle.
(He also warned me that "you'll need to make quite some changes if you are depending on certain UT* classes").

I found by making a mod, like so.

class MyGameModGame extends UTGame;

DefaultPawnClass = class'UTVehicle_Scorpion_Content';

From my understanding (and guestimations) this spawns me as a this vehicle. But my controls to be able to drive, or do anything else are not assigned.

If this isnt correct, could anyone point out what Im not sure of, and if possible, pointers on where to goto next.

Cant seem to find any vehicle code online, although I did manage to find UnWheel2 as a UDK project (both cooked and uncooked) so I'm hoping this means there is source code for me to look through.


<elmuerte> don't know what things, you just have to look what doesn't work
<elmuerte> you need to make sure the inputhandling is properly directed to the vehicle for example
<elmuerte> just check what stuff is done in "player enters vehicle"

03-23-2010, 09:08 AM
I missed you on the IRC, but have you looked at the playercontroller class? There's a PlayerDriving state, maybe setting that state at startup (or as default) will do the trick?

You might need to use the UT playercontroller class, I'm not sure. But it's probably some of the problem. Hope this helps!

03-23-2010, 10:18 PM
Looked through some of the functions, cant see why the input would just be lost though.
I seen some states but PlayerDriving is not in UTPlayerController, but it is in PlayerController, superclass of UTPlayerController.

Are the functions such as PlayerMove hooked up to events? I did a search in all source, and they are only time they are called is when its super.PlayerMove(

03-24-2010, 03:14 AM
The easy way to do this is to assign a new pawn class which is your vehicle driver, from there you make this driver enter the vehicle as soon as your game starts. That should fix your input problem perhaps.

03-24-2010, 04:14 AM
Yes, but that could be achieved via kismet if I needed it. I will look into it though i guess.
Would be good to find the way I was originally going, then i could write up a FPS to Racing tutorial for UDK.

03-24-2010, 04:31 AM
Im pretty sure UnWheel works similarly though I only know from what Ive seen one of the developers post, I use the exact same method as they did for spawning my Jet for a top down shooter. Basically a Pawn as a driver is a requirement when subclassing UT stuff, there isnt a huge choice when it comes to extending UT prefix vehicles unless you plan on writing all your physics from scratch (perhaps implementing dllbind for native like performance).

Anyways I have acouple of points here, one is that tutorials called 'FPS to Racing' are too specific when the core functionality can go past using it for just a racing game. The second is why you want 'just' a vehicle to spawn in a racing game when those more often then top down shooters have a visible driver. My first thought for this was having the pawn attached to the vehicle you can still access its eye poisition so you can get a true first person driving camera with little fuss.

Anyways if you look at the movement, I think its ProcessMove and ServerMove etc, I think you'll find there is a ProcessDrive and ServerDrive also. Im going to suggest working with the engine and not against it, youre coding time will be much more fruitful that way :cool:

03-24-2010, 05:58 AM
I'll emails the devs of UnWheel and see what they did.

Reading the kismet version of spawning your player, then entering a vehicle is bad, and apparently you see your player before you enter the vehicle.. I assume the unrealscript version of this is MUCH better. Will go try it now.

The second is why you want 'just' a vehicle to spawn in a racing game when those more often then top down shooters have a visible driver. My first thought for this was having the pawn attached to the vehicle you can still access its eye poisition so you can get a true first person driving camera with little fuss.

The vehicle will have 2 seats, so it will require 2 players to play the game (via LAN). A visible driver is most probably not required. Also have to limit camera to an internal camera, with limited range of movement. But thats not until later I guess.

I'll get some stuff happening now, and see where I get and update my post.

03-24-2010, 06:54 AM
class SLK_GameInfo extends UTGame

var() class<UTVehicle> DefaultVehicleClass; // The default vehicle class that the player starts in

* Restarts a player by giving him a pawn and a vehicle
function RestartPlayer(Controller aPlayer)
local UTPlayerController PC;

PC = UTPlayerController(aPlayer);
if(PC != None)
// can't respawn if you have to join before the game starts and this player didn't
if(bMustJoinBeforeStart && PC != None && PC.bLatecomer)

// can't respawn if out of lives

// Super.RestartPlayer(aPlayer);

if(aPlayer.Pawn == NONE)


/* Spawn player inside of a vehicle.*/
unreliable server function SpawnUVehicle(Pawn P)
local Vehicle V;
local vector loc;

loc = P.Location;
//loc += vect(0,0,default.FlightAltitude);
loc.Z += default.FlightAltitude;

//Change the class to your extended vehicle or to scorp_content
V = Spawn(DefaultVehicleClass,,,loc, P.Rotation);
`logd(V$": Spawning vehicle!",,'Silky');
if(V != none)
if(V != none && V.TryToDrive(P))

`log(V$": Attaching driver!",,'Silky');

DefaultVehicleClass=Class'SilkyGameContent.SLK_Jet _Viper'
DefaultInventory.Remove(class'UTWeap_LinkGun') //This is because I was getting wierd things happening like linkgun functions still being called even whilst spawning straight to a vehicle

I just use this and override all the functions that allow a player to leave a vehicle, SLK_Pawn is just a dummy class basically and contains no functionality. Im not sure of the overhead of having a Pawn+Vehicle but I cant imagine it would be that high since theres still the Controller which moves from one to the other.

03-24-2010, 07:33 AM
cheers. Code I was looking at was pretty much along these same lines. I'll plug it all in and work on it some more tomorow.

03-25-2010, 02:42 AM
default.FlightAltitude was not found, just replace that with a value that wont kill me, and it works.
Need to adjust the ability to exit vehicle thou, and vehicle taking damage and it should be all good.

04-11-2010, 07:13 AM
class RCMain extends GameInfo;
event PlayerController Login(string Portal, string Options, const UniqueNetId UniqueId, out string ErrorMessage)
local NavigationPoint StartSpot;
local PlayerController NewPlayer;
local string InName;
local rotator SpawnRotation;
local UTVehicle_Scorpion_Content theCarpawn;
local Pawn thepawn;
StartSpot = FindPlayerStart( None, 0, Portal );
if( StartSpot == None )
ErrorMessage = PathName(WorldInfo.Game.GameMessageClass) $ ".FailedPlaceMessage";
return None;
SpawnRotation.Yaw = StartSpot.Rotation.Yaw;
NewPlayer = SpawnPlayerController(StartSpot.Location, SpawnRotation);
if( NewPlayer == None )
`log("Couldn't spawn player controller of class "$PlayerControllerClass);
ErrorMessage = PathName(WorldInfo.Game.GameMessageClass) $ ".FailedSpawnMessage";
return None;
NewPlayer.StartSpot = StartSpot;
thepawn = spawn(class 'RCPawn' ,,,StartSpot.Location+Vect(0,0,100)); //+100 to make shur the two pawns dose not get stuck
theCarpawn = spawn(class 'UTVehicle_Scorpion_Content',,,StartSpot.Location) ;
theCarPawn.TryToDrive(thePawn);//The ****!
return NewPlayer;

This works for me!

11-11-2010, 09:32 PM
using september 2010>dunno what im doing wrong but when i die i dont respawn oh and it tole me to take out "
local string InName;
dunno y but it wouldnt start untill i took it out

i start in the vehicle but dont respawn :(

11-30-2010, 03:27 AM
Slinker, that worked perfectly...

Who would have thought, just hours before due date that this was solved.... :)