I am am new at this unreal srcipt. I want to how I can spawn the vehicle when the game start up instead of an character. I am trying to make a custom game type for this part to work. I don't know where to start or learn how to do this.
Any one?
I am am new at this unreal srcipt. I want to how I can spawn the vehicle when the game start up instead of an character. I am trying to make a custom game type for this part to work. I don't know where to start or learn how to do this.
Any one?
Blender 2.64 Plugin Export Script PSK/PSA
http://forums.epicgames.com/showthread.php?t=747452
Blender 2.49b Plugin Export Script PSK/PSA
http://forums.epicgames.com/showthread.php?t=602953
http://unrealtacticalmod.googlecode.com
Two things possible:
1. Before the pawn is spawned, you specify that the game spawns the vehicle for the Controller, ie the Controller's Pawn class is the vehicle. Problem with this I think, is that the player will drive an empty vehicle. This should only require a default property change.
2. When the player spawns, a vehicle spawns in his location and the Controller is made to drive it. Here the player should show up inside the vehicle. Problem with this is that spawning the vehicle onto the freshly spawned Pawn could result in crushes. This should even be possible in a Mutator (function ModifyPlayer()).
Small note: I talk from UT2004's coding experience, not UT3's.
I see. But which code should I work on? New custom game mod or use the mutator class. I am trying to code a one of the following game types; vehicle death match, race course, air plane combat.
Some may work with out getting crush.
I guessing I need to know how to setup the for custom game type that need for this code to work. For now I need to know how to replace player for vehicle spawning.
---
Not sure where to replace the player for a vehicle.
Code:class CustomGame extends UTDeathmatch config(game); function PostBeginPlay() { local UTGame Game; local int i;//, Index; Super.PostBeginPlay(); // remove default weapons Game = UTGame(WorldInfo.Game); if (Game != None){ for (i = 0; i < Game.DefaultInventory.length; i++){ `log("[Reamove Weapon] - Initialized and running" @ Game.DefaultInventory[i].Name); Game.DefaultInventory.Remove(i, 1); i--; } } } defaultproperties { MapPrefixes(0)="DM" MapPrefixes(1)="VDM" OnlineGameSettingsClass=class'mymod.UTGameSettingsVDM' //OnlineGameSettingsClass=class'UTGameSettingsCTF' GameName="VehicleDeathMatch" }
Last edited by darknet; 03-24-2008 at 01:39 AM.
Blender 2.64 Plugin Export Script PSK/PSA
http://forums.epicgames.com/showthread.php?t=747452
Blender 2.49b Plugin Export Script PSK/PSA
http://forums.epicgames.com/showthread.php?t=602953
http://unrealtacticalmod.googlecode.com
I found code that player can be spawn as vehicle, but I can't control it.
I look into the UTGame class. I don't how to get the vehicle moving when the player is the car instead of the character. I don't know how playercontrol class works. Any one?Code:class UTVehicleDeathMatch extends UTDeathmatch; defaultproperties { //PlayerControllerClass=class'UTGame.UTPlayerController' //ConsolePlayerControllerClass=class'UTGame.UTConsolePlayerController' //BotClass=class'UTBot' DefaultPawnClass=class'UTGameContent.UTVehicle_Scorpion_Content' }
Blender 2.64 Plugin Export Script PSK/PSA
http://forums.epicgames.com/showthread.php?t=747452
Blender 2.49b Plugin Export Script PSK/PSA
http://forums.epicgames.com/showthread.php?t=602953
http://unrealtacticalmod.googlecode.com
I'm stuck at the same point.
I can spawn as a vehicle by setting default pawn class as a vehicle:
DefaultPawnClass=class'UTGameContent.UTVehicle_Man ta_Content'
But when I launch the game the Manta just can shoot and "jump", but I cannot move... I've looking for some solutions but I can't find one.
I think that it's a PlayerController matter, but I just can't figure how to make it work.
Any tips?
Copy-paste is not always the best solution. In order to things working, you need to investigate much time in readine different code and trying easy step-by-step codes.
The UTVehicle needs a UTPawn. Using a vehicle as DefaultPawnClass won't work properly.
If you want to write a custom game type you could start with this. Basic function.
MyGame
MyDriverPawnCode:class MyGame extends UTGame; var String VehicleClass; function RestartPlayer( Controller aPlayer ) { Super.RestartPlayer( aPlayer ); if (aPlayer.Pawn == none) { `log("No Player pawn."); return; } SpawnVehicle( aPlayer.Pawn ); } /** * Spawns a Vehicle and attaches the pawn to the given Vehicle * @param P the Pawn which will be attached to the vehicle * */ reliable server function SpawnVehicle( Pawn P ) { local class<actor> NewClass; local Vehicle V; if (P == none) //NULL safety check return; if( SpawnClass(VehicleClass, NewClass )) { V = Vehicle(Spawn( NewClass,,,P.Location,P.Rotation )); if (UTVehicle(V) != none) { UTVehicle(V).SetTeamNum(P.GetTeamNum()); } AttachDriver(P,V); } } /** Spawns a class * @param ClassName the full name of the class * @param ClassObj the spawned object * @return true, if the class is loaded. * */ function bool SpawnClass(String ClassName, out class<Actor> ClassObj) { ClassObj = class<Actor>( DynamicLoadObject( ClassName, class'Class' ) ); return (ClassObj != none); } reliable server function AttachDriver(Pawn P, Vehicle V) { if (V != none) { if (V.TryToDrive(P) ) { return; } V.AttachDriver(P); } else { `log("Couldn't spawn player of type "$VehicleClass); } } DefaultProperties { DefaultPawnClass=class'MyDriverPawn' VehicleClass="UTGameContent.UTVehicle_Scorpion_Content" }
The following code is a mutator to provide basic function to start with a vehicle.Code:class MyDriverPawn extends UTPawn; function PlayTeleportEffect(bool bOut, bool bSound); defaultproperties { bCollideActors=false bGameRelevant=true }
MyMutator
Code:class MyMutator extends UTMutator config(MyConfig); var config string VehicleClass; var config bool bVehicleOnly; var config bool bDestroyVehicleOnExit; var config bool bAllowVehicleSuicide; function PostBeginPlay() { super.PostBeginPlay(); SaveConfig(); } function bool CanLeaveVehicle(Vehicle V, Pawn P) { if (bVehicleOnly) { if (bAllowVehicleSuicide && IsVehicleSuicideReady(V)) { return true; } return false; } else { return super.CanLeaveVehicle(V, P); } } function DriverLeftVehicle(Vehicle V, Pawn P) { super.DriverLeftVehicle(V, P); if (bDestroyVehicleOnExit && !IsVehicleSuiciding(V)) { V.Died(None, class'DamageType', V.Location); } } function bool IsVehicleSuicideReady(Vehicle V) { if (UTVehicle_Viper(V) != none && UTVehicle_Viper(V).bSelfDestructReady) { return true; } else if (UTVehicle_Scorpion(V) != none && UTVehicle_Scorpion(V).bBoostersActivated) { return true; } return false; } function bool IsVehicleSuiciding(Vehicle V) { if (UTVehicle_Viper(V) != none && (UTVehicle_Viper(V).bSelfDestructReady || UTVehicle_Viper(V).bSelfDestructInProgress || UTVehicle_Viper(V).bSelfDestructArmed )) { return true; } else if (UTVehicle_Scorpion(V) != none && (UTVehicle_Scorpion(V).bBoostersActivated || UTVehicle_Scorpion(V).bSelfDestructArmed)) { return true; } return false; } function ModifyPlayer(Pawn Other) { super.ModifyPlayer(Other); Other.SetCollision(false); if (!SpawnVehicle( Other )) { Other.SetCollision(true); } } function bool SpawnVehicle( Pawn P ) { local class<actor> NewClass; local Vehicle V; if (P == none) //NULL safety check return false; if ( SpawnClass(VehicleClass, NewClass) ) { V = Vehicle(Spawn( NewClass,,,P.Location,P.Rotation )); if (V == none) { return false; } if (UTVehicle(V) != none) { UTVehicle(V).SetTeamNum(P.GetTeamNum()); } AttachDriver(P,V); return true; } else { return false; } } function bool SpawnClass(String ClassName, out class<Actor> ClassObj) { ClassObj = class<Actor>( DynamicLoadObject( ClassName, class'Class' ) ); return (ClassObj != none); } function AttachDriver(Pawn P, Vehicle V) { if (V != none) { if (V.TryToDrive(P) ) { return; } V.AttachDriver(P); } else { `log("Couldn't spawn vehicle of type "$VehicleClass); } } DefaultProperties { bVehicleOnly=true bDestroyVehicleOnExit=true bAllowVehicleSuicide=false VehicleClass="UTGameContent.UTVehicle_Scorpion_Content" }
You may also check the code of this UDK sample code.
http://udn.epicgames.com/Three/Devel...tarterKit.html
PS: You should try to use different search engines. http://forums.epicgames.com/threads/...side-a-vehicle
This thread is quite old.
Yeah, I know it's old, but never figured out how to achieve the point of spawning as a vehicle instead as a "pawn".
Already done, as you said, it takes a lot of reading. Thnx anyway =)
HI.
Am a grad student new to Uscript.
Am trying to spawn a vehicle instead of player.
But am not able to achieve with the code what i have written.
Please help me if i have gone wrong somewhere.
This is my GameInfo class
This is my pawn classCode:class mygameinfo extends UTGame; var String VechileClass; var Vehicle yourvehicle; var PlayerController P; var vector alteredlocation; function RestartPlayer( Controller aPlayer) { super.RestartPlayer(aPlayer); startspawning(); } exec function startspawning() { local PlayerController pc; `log("Spawn Players in Vehicles"); pc.GotoState('PlayerVehicleState'); } state PlayerVehicleState { Begin: spawnplayersinvehicle(); } exec function spawnplayersinvehicle() { foreach worldInfo.AllControllers(class'PlayerController',P) { alteredlocation = P.Pawn.Location; alteredlocation += vect(100, 100, 100); SetCollision(false, false); yourvehicle = Spawn(class 'UTGameContent.UTVehicle_Scorpion_Content',,, alteredlocation, P.Pawn.Rotation); SetCollision(false, false); yourvehicle.AttachDriver(P.Pawn); } } simulated event PostBeginPlay() { `log("Player restart"); super.PostBeginPlay(); } DefaultProperties { DefaultPawnClass = class'blur.mypawn' PlayerControllerClass = class'blur.mycontroller' }
Controller ClassCode:class mypawn extends GamePawn; simulated function PostBeginPlay() { super.PostBeginPlay(); `log("Custom Pawn UP"); } DefaultProperties { }
Code:class mycontroller extends PlayerController; simulated function PostBeginPlay() { super.PostBeginPlay(); `log("Player Controller Initialized"); } //state PlayerDriving //{ //Ignores SeePlayer, HearNoise, Bump; // function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot); // function ProcessDrive(float InForward, float InStrafe, float InUp, bool InJump) // { // local myvechile CurrentVechile; // CurrentVechile=myvechile(pawn); // if(CurrentVechile != none) // { // bpressedJump = InJump; // CurrentVechile.SetInputs(InForward, -InStrafe, InUp); // CheckJumpOrDuck(); // } // } // function PlayerMove(float DeltaTime) // { // UpdateRotation(DeltaTime); // ProcessDrive(PlayerInput.RawJoyUp, PlayerInput.RawJoyRight, PlayerInput.aUp, bPressedJump); // if(Role < ROLE_Authority) // { // ServerDrive(PlayerInput.RawJoyUp, PlayerInput.RawJoyRight, PlayerInput.aUp, bPressedJump, ((Rotation.Yaw & 65535) << 16) + (Rotation.Pitch & 65535)); // } // bPressedJump = false; // } // event BeginState(Name PreviousStateName) // { // cleanOutSavedMoves(); // } // event EndState(Name NextStateName) // { // CleanOutSavedMoves(); // } //} DefaultProperties { //PawnClass=Class'blurring.mypawn' }
Last edited by rkamumar; 10-31-2012 at 01:05 PM.
Hmm. Where should i start?
I will disregard the Pawn and Controller class (mycontroller and mypawn) as they doing nothing (in your example code).
What should "startspawning" do?
Let's take a look. You're defining the method. It will give a a log whenever it gets executed. And it tries to call the function "GotoState" with a given parameter on the object PC.
This will always fail. (You should get a message on compiling like "local variable used before assigned a value").
Keywords: declaration, instantiation
But let's ignore that. So you're trying to force the GameInfo class to get into the PlayerVehicleState state. And this state should call spawnplayersinvehicle whenever that state starts to execute. Let's assume the startspawning method would work, so you trying calling the methods everytime A player spawns (which will call RestartPlayer on the GameInfo class which is played, i your case mygameinfo) and it will try to spawn for every controller of your world a vehicle and will attach that player to that newly spawned vehicle.
I would doubt you're trying to achieve something like that.
But for now on let's take a quick look on your code inside the for loop.
You're setting a new position somehwere different to the pawn location (i think your'e doing that because spawning a vehicle on top of a pawn will either move/destroy/block the vehicle or will kill the pawn).
The next thing, you're trying to change the collision (for something). Well, you're calling SetCollision for the own actor --> in your case the instance of your mygameinfo class.
You're doing that twice. You probably wanted to call
By looking at your PostBeginPlay function i notice your log message "Player restart".Code:alteredlocation = P.Pawn.Location; alteredlocation += vect(100, 100, 100); P.Pawn.SetCollision(false, false); yourvehicle = Spawn(class 'UTGameContent.UTVehicle_Scorpion_Content',,,alteredlocation, P.Pawn.Rotation); yourvehicle.SetCollision(false, false); yourvehicle.AttachDriver(P.Pawn);
I guess you're confused of what the GameInfo class should do at all and what to do with the Pawn class.
Let's do something similar which will work. (the basic functionality)
GameInfo class
Pawn classCode:class mygameinfo extends UTGame; function RestartPlayer( Controller aPlayer) { super.RestartPlayer(aPlayer); // the RestartPlayer function of UTGame/GameInfo will spawn a DefaultPawn for the Player // this is just a safety check wether there is a Pawn. if (aPlayer != none && aPlayer.Pawn != none ) { // Now force the Pawn to go to the PlayerVehicleState // that state will not work for the stock Pawn class, but for your own class aPlayer.Pawn.GotoState('PlayerVehicleState'); } } DefaultProperties { DefaultPawnClass = class'blur.mypawn' //PlayerControllerClass = class'blur.mycontroller' }
I hope you get a closer look in how to achieve something like that. In additoin, you can use my previous posted code. It should work flawlessly.Code:/* * Extending GamePawn is working for vehicle. * But to control weapons for the vehicle like the Scoprion, we need to use UTPawn * * class mypawn extends GamePawn; */ class mypawn extends UTPawn; var Vehicle yourvehicle; simulated function PostBeginPlay() { super.PostBeginPlay(); `log("Custom Pawn UP"); } state PlayerVehicleState { event BeginState(Name PreviousStateName) { `log("Begin PlayerVehicleState"); super.BeginState(PreviousStateName); spawnplayerinvehicle(); } /* * In general: Don't use Spagetti code. Try to do proper OO-prgoramming-style Begin: spawnplayersinvehicle(); */ } exec function spawnplayerinvehicle() { local vector alteredlocation; `log("spawnplayerinvehicle"); alteredlocation = Location; // no need to alter position as the pawn has no collision //alteredlocation += vect(100, 100, 100); /* * by using the line SetCollision(...) * it will call this: self.SetCollision(...) * It's different to use it in this instance (of mypawn) than in the instance of mygameinfo */ SetCollision(false, false); yourvehicle = Spawn(class 'UTGameContent.UTVehicle_Scorpion_Content',,, alteredlocation, Rotation,, // set NoCollisionFail for spawning the vehicle in every case true ); // safe check. Otherwise a warning message of "Accessed None" will occur in the log. if (yourvehicle != none) { // no need to set collision for that vehicle //yourvehicle.SetCollision(false, false); `log("spawnplayerinvehicle - trying to drive"); if (yourvehicle.TryToDrive(self) ) { `log("spawnplayerinvehicle - drive"); return; } `log("spawnplayerinvehicle - attach driver"); yourvehicle.AttachDriver(self); } } DefaultProperties { }
PS: You don't need to quote the whole post when you don't respond to it.
It depends on the game your setting up and on the classes your using but basically yes. The basic system of a game is to spawn players at given PlayerStarts.
I really suggest to read the Tutorial for UDK created by Epic staff on how to create a Racer-like game.
PS: Check the UDK sub-forum for more help on UDK type of things.
PPS: A post after a post is always in relation to (some of) the previous post. Check "Reply" (which is different to "Reply with quote") or just use the "Quick Reply" feature.
PPPS: Sorry if i sound (or sounded) upset. I just wanted to give you hints about the redundant (and useless) quotes.
I have done exactly what you told but still the player spawns as a pawn only.
Also none of the above "`log" worked.
Does that mean it has something to do with my .ini files?
My example is using UT3 not UDK. UDK is different. "`log" logs the message to the Log (stdout) not to the console or to the HUD screen. Open the log by typing "showlog" into your console.
You should explain what exactly you're doing and what you already did. Otherwise it's like groping in the dark for me.
Hint: By using PIE in UDK, you should set the PIE Gametype to your gameinfo class in order to play the specific game type.
My project is about motion blur so all i need to do is run a vehicle on a simple track and implementing my motion blur algorithms in it.
Oh.. i tried changing my gametype in UDK but had no luck.
This code works great in single player but when I try to use it in multiplayer it spawns my pawn and not the vehicle, then the camera turns 90 degrees to the right with no pawn anymore and then I'm in the vehicle but the guns dont work and theres no crosshairs for the vehicle until I die or respawn another way, then everything works. Also it doesn't work at all in unreal frontend, I just start as the pawn.
Does anyone know why this is? Or know a work around for it?
Thanks!
I might have to look at the code again. I got something like that working online before i wrote this code snippet.
Can u name the vehicle you are using?
"Unreal Frontend"? You mean the UnrealEd (Unreal Editor)?
Using custom gametypes in the editor is a bit tricky. By default, the game search for the gamemode to play a map with that specific prefix. There is a workaround (but i don't know that one currently).
Hey thanks for the reply.
I actually got it working with someone else in this thread here http://forums.epicgames.com/threads/...ng-Game-Glitch
A small problem with one of my booleans that controls if the camera is free roam or locked in controlling the ship has arisen though. It stopped replicating once I made those changes in that thread but I think I will be able to fix it on my own. If not I will post again lol
Okay.
Btw. there is a reason to spawn the class (and not directly in object of a class). Having a custom vehicle which cannot be found on compiling (like CaptainSnarfs vehicles) would result into an error (and removes the definition off the binary script file) which will result into spawning a "NONE" object. This example game type works flawlessly in UT3 (UDK is not tested). The mutator does the same as the gametype - only use the gametype or the mutator.
Glad, that someone could help you.
Oh ok good to know. In relation to that little problem I mentioned a couple posts ago. I still haven't been able to get it fixed since I got your code working.
Basically the playerinput I'm using now to control the camera isn't getting replicated to the server. Do you know why this could be?
Heres my post I made a few hours ago asking for help if you wan't to reply their instead, nobody seems to know.
http://forums.epicgames.com/threads/...ting-a-rotator
Bookmarks