Game Development Community

T3D 1.2 New Level SpawnSphere(s)?

by SqHd · in Torque 3D Professional · 04/22/2012 (8:12 pm) · 12 replies

Good evening,

I recently upgraded to 1.2 (yea!) and have been playing around with the Chinatown (FPS Tutorial project). I created a new level from the editor with the classic grey ground plane, character, and SpawnSphere(s). I am hoping someone could shed some light on why there are 3 SpawnSpheres and how they work.

I am used to the regular one that is in the simset PlayerDropPoints (although it doesn't seem to be in use). There are 2 others: DefaultPlayerSpawnSphere and DefaultCameraSpawnSphere (which do not show the actual green sphere if you click on them). Neither shows up in the Scene Tree nor can they be deleted. If I move them and save, they just go back to the origin next time I start up the level.

Plus, the character doesn't spawn near them. (It says the radius and various sphereWeights are deprecated in the Inspector). And one final note, when the level loads, I am in camera mode (instead of the character) and floating inside the mesh.

I'm sure I am just missing something simple that is a new feature of the upgrade (possibly in the scripts). Thanks.

#1
04/22/2012 (9:13 pm)
I believe there are two types of spawnSphere here. DefaultPlayerSpawnSphere and SpawnSphere. You'll notice that the first is for the player/s to spawn somewhere on the map. It has a radius of 100 and is not shown in the scene window. The other has a radius of 5 and is for spawning other either other players or those turrets. I'm really not sure to be honest. In your new level it'll be unassigned. You'll have to tell it what class to spawn. As far as I know that's what they are, but I haven't really touched those things yet.
#2
04/24/2012 (12:34 pm)
Thanks for the info. Now I just need to figure out how to delete the DefaultPlayerSpawnSphere or control where it spawns a character. Guess I'll go hunting in the scripts...
#3
04/24/2012 (2:55 pm)
DefaultPlayerSpawnSphere is simply a name given to a specific SpawnSphere instance -- there may or may not be some code somewhere that calls it by name.

The default methods of the spawn process look for various names of a Simset in order to find a potential SpawnSphere. If a SpawnSphere is not located within a defined Simset, then it is not seen by the spawn scripts. If there are more than one, then a SpawnSphere is chosen at random. Some default spawn-related global variables that control the type of spawn (player or camera), name of the Simset(s), Default player/camera datablock, etc, can be found in core/scripts/server/spawn.cs - but be aware that these defaults may be overridden depending upon project and gameType. The empty Template doesn't override the core methods but does redefine the spawn related global variables in scripts/server/game.cs; the Full Template and FPS Example overrides methods and global variables within the scripts/server/gameCore.cs script file, which in turn may be overriden by a specific gametype.

Disclaimer: I've never taken more than a cursory glance at the FPS Tutorial, so it may do things a bit differently... although I doubt it since it is basically the Full Template (or FPS Example) with assets and GUI changes.

When you create a spawn marker in the Editor take note of the various drop-down boxes. Also, to make use of the stock spawn methods you will need to create the marker within the proper Simset, or move it there manually.

The weight properties can be used to prioritize a series of spawn points, although there is no code in the stock scripts that does so.

And of course, custom script can completely change how you handle spawning. Stock code is only an example.
#4
04/24/2012 (3:28 pm)
DefaultPlayerSpawnSphere isn't a different type of SpawnSphere, that's the object name. DefaultPlayerSpawnSphere is created and added to the world in script, which is why you can't manipulate it in the editor. It only gets created if the SimSet that is passed to pickPlayerSpawnPoint either doesn't exist or contains no spawnpoints.

New levels still use the old name for the player spawns SimSet, PlayerDropPoints, as it used by the other templates. The default SimSet was changed to PlayerSpawnPoints as it was determined that terminology was friendlier to new users. Just change the PlayerDropPoints SimSet in your new level to PlayerSpawnPoints, or you can just add PlayerDropPoints $Game::DefaultPlayerSpawnGroups in spawn.cs.
#5
04/25/2012 (6:59 pm)
Great! Thanks for the tips!
I changed the SimSet to PlayerSpawnPoints and the extra DefaultPlayerSpawnSpere and DefaultCameraSpawnSphere disappeared. Now the character spawns at the SpawnSphere same as in the Chinatown level.

Only problem I have now is when playing a level (any of the levels, not just the new one), you start as the camera instead of the character.

Again, thanks for the help. I really appreciate it!
#6
04/25/2012 (10:40 pm)
Quote:
Only problem I have now is when playing a level (any of the levels, not just the new one), you start as the camera instead of the character.
Check that you filled out the SpawnClass and SpawnBlock properties with valid information. If these are not found then the stock code forces a camera to be spawned -- this is done as a safety precaution.
i167.photobucket.com/albums/u143/heretek/torque/spawnProps.png
#7
04/25/2012 (10:47 pm)
Some more neat tips or tricks:
  • You can spawn as a vehicle if you fill out those properties with a vehicle classname and valid vehicle datablock.
  • You can spawn an AI bot instead of player - but it will need some direction.
  • You could apply custom properties to the object which is spawned at 'this' marker.
  • You can include a custom function to be ran when a spawn marker is used, by filling in the spawnScript information.
  • You are not limited to spawning just Players, Cameras, or Vehicles.
  • With some creative scripting you could actually use spawn markers as teleport locations.
#8
04/26/2012 (1:22 pm)
You can use spawn markers as just about any sort of marker, really. In the Scripting/Advanced/Adventure Prototype we used them as camera markers. In the Scripting/Advanced/Mission Triggers tutorial we used them as inter-mission teleport targets. (Sorry - for some reason linking directly to the pages didn't work) I've used them as spawn points for other objects as well, not just AI or Players.

Also - take a look in scripts/server/gameDM.cs -

function DeathMatchGame::initGameVars(%game)
{
   //echo (%game @"c4 -> "@ %game.class @" -> DeathMatchGame::initGameVars");

   //-----------------------------------------------------------------------------
   // What kind of "player" is spawned is either controlled directly by the
   // SpawnSphere or it defaults back to the values set here. This also controls
   // which SimGroups to attempt to select the spawn sphere's from by walking down
   // the list of SpawnGroups till it finds a valid spawn object.
   // These override the values set in core/scripts/server/spawn.cs
   //-----------------------------------------------------------------------------
   
   // Leave $Game::defaultPlayerClass and $Game::defaultPlayerDataBlock as empty strings ("")
   // to spawn a the $Game::defaultCameraClass as the control object.
   $Game::defaultPlayerClass = "AIPlayer";
   $Game::defaultPlayerDataBlock = "DemoPlayerData";
   $Game::defaultPlayerSpawnGroups = "PlayerSpawnPoints PlayerDropPoints";

   //-----------------------------------------------------------------------------
   // What kind of "camera" is spawned is either controlled directly by the
   // SpawnSphere or it defaults back to the values set here. This also controls
   // which SimGroups to attempt to select the spawn sphere's from by walking down
   // the list of SpawnGroups till it finds a valid spawn object.
   // These override the values set in core/scripts/server/spawn.cs
   //-----------------------------------------------------------------------------
   $Game::defaultCameraClass = "Camera";
   $Game::defaultCameraDataBlock = "Observer";
   $Game::defaultCameraSpawnGroups = "CameraSpawnPoints PlayerSpawnPoints PlayerDropPoints";

   // Set the gameplay parameters

These let you set the default player types that the spawning functions use for the "last resort" so that you should be able to simply make the $Game::defaultPlayerClass = "Player"; and avoid the problem of spawning as an observer cam.

Of course, that should actually be the default anyway - there may be another problem in play....
#9
04/26/2012 (3:43 pm)
Well, I made sure my spawnClass and spawnDatablock were correct and then I decided to compare my new level .mis file with one of the Chinatown .mis files. I had an extra " =1;" in my "new SimGroup(PlayerSpawnPoints)" function. Not sure how it got there, but once I deleted it and started up the mission, I spawned as the soldier!

@Michael Hall: Nice! I was wondering how to spawn as a vehicle. My friends and I used to play Rush 2049 on the Dreamcast (Battlemode) so I want to mess around making some car battle levels sometime. Thanks!

@Richard Ranft: Thanks for the heads up on the scripting documentation (I never checked that section out) and explanation of gameDM.cs. Definitely useful info.
#10
05/19/2012 (9:51 am)
@Michael: Any chance for a quick explaination of how to add a vehicle class / datablock to spawn as the Cheetah? I am not having any success with where /how to create the class...Thanks!
#11
05/19/2012 (10:28 am)
For the Full Template and Empty Terrain mission get into the game (or hand modify the EmptyTerrain.mis) and select the existing SpawnSphere. Change the SpawnClass to WheeledVehicle, and change the SpawnDatablock to CheetahCar. Save the level and reload. You will spawn and have control of the Cheetah.

Apparently the Cheetah has a poorly positioned eye node so you'll want to switch to 3rd person.
#12
05/19/2012 (11:36 am)
Thanks! That was much easier than I was making it!