Spawn point and custom gizmo tutorial

Hi all, got a new tutorial on how to create a small spawn point for a prefab object as well as how to set its custom gizmo in the editor.

Be sure to have also read my tutorial on how to load an xml file from resources so that you can properly understand how to dynamicaly load a prefab from the Assets/Resources folder.

This can be good for game designers who want to spawn dynamic actors or game objects at certain points. I know the Quake3 editor used a similar technique (more or less advanced).

I tried all of this and it didn’t work, nor were your ‘tutorials’ comprehensive enough to walk though the process to beginners (non-programmers)

Also, in your code for Spawn Point Gizmo, an error pops up for me:
"The name ‘WorldSpawnPoint’ does not denote a valid type.

I’ve been searching for weeks now on a decent tutorial and advice on how to randomly spawn my objects into the scene (dynamically increasing over time) and have yet to find anything that works (nor tutorials that make sense to the non-programmer).

Some of us writers/designers/artists really do need it spelt out to us from the beginning :slight_smile:

Well I think you would need to brush up on your coding skills, this tutorial is very basic, like you said you may need to deepen your knowledge of how to program. This can be done with looking at the platformer tutorial.

My apologies, but the grammar in this tutorial is also pretty awful. There are a few run-on sentences, which I had to look over multiple times to understand what you meant (Example: “That is because Unity3d editor static function only work with Unity basic type not any created by us.” Upon further inspection, I realized you were saying Unity3D’s static functions only works with basic types, nothing custom.) The first thing you could do to improve this helpful tutorial is to take some time to proofread. I personally find it an intellectual turn off to read something I have to decipher - you may or may not know it (and I think you do know it, definently better than I), but it dosen’t look like you know it if you do a bad job of explaining it. Again, no offense intended.

On the subject of a bad job of explaining a process, though, this tutorial in truth dosen’t do a good job of explaining a lot at all, and I am a programmer. What I gather from reading this is: We’re creating an Editor folder, and copying that script you supplied. We need to have a WorldSpawnPoint component (is it a script? Is it a so-named object? What is this “WorldSpawnPoint” you have contrived?) You then tell us to watch what we make the WorldSpawnPoint point to, because it could point to theoretically anything, then tell us to write a second, uncommented script.

What I gather this script does (comments describe what I see in this):

// Declare script variables.  I am
// Unsure why these have to be public
// variables - these are only used to
// "spawn" (read: copy) our spawnable
// object.
public var ActorPrefab:String = "Aki";
public var IsMainActor:boolean = false;

// Function that will be run when the scene is started...
function Start()
{
  // Create an instance of our "ActorPrefab".
  var actor:GameObject = GameObject.Instantiate(Resources.Load(ActorPrefab, GameObject));

  // If we did not create an instance, log the error!
  if(actor == null)
  {
    Debug.LogError("World Spawn Point could not instantiate actor : " + ActorPrefab);
  }
  else
  // Place our copy at the spawn point's location.
  // For nonprogrammers, a bit of inference: this
  // script is added to our spawn point GameObject,
  // and inherits our spawn point object's location
  // and rotation.
  {
    actor.transform.position = transform.position;
    actor.transform.rotation = transform.rotation;

    if(IsMainActor)
    {
      // Do something with this actor.  Like what,
      // exactly?  Register it to a manager?  Ok.
      // what else do we do with main actors?
      // Some explanation outside of the code of
      // things this if block could do would prove
      // helpful.
    }
  }
}

Your supplied script is a simple, textbook spawn point. We take a resource, copy it, put it at the spawn point’s location and give it the spawn point’s rotation so it’s facing the default direction.

…And the tutorial ends there, with naught more than a farewell. If you intended to write something helpful, please take no offense from my criticisms, but go back and clarify your process! If you were simply showing off what you were doing, why did you bother writing this “tutorial?” A video or webplayer demo would have sufficed, in that case.

I apologize if any of what I have expressed in this post seems overly harsh, but I think you have a little revising to consider. Your tutorial is at least a start, and could potentially be most helpful! I wish you luck on your project.

Bah, you cannot always get it right :), I totally agree it needs some sort of revision. I will try to improve it to be really helpful, as for what you can do with a spawned actor its pretty open to what your game does.

Touche. Good point on the OnSpawn if block, that was me getting zealous.

:stuck_out_tongue:

Still, it was extremely helpful to me. I am learning Unity’s scripting hooks, and thanks to you I now solidly know Unity’s location and rotation hooks! Go Hotdot!

Didn’t i say i wasn’t a programmer? So what would i be brushing up on exactly?

Another arrogant programmer I see - very disappointing.

Mate, don’t even write “Tutorials” if you’re not prepared for the questions later, no matter how ‘dumb’ they seem to you

Good luck in your life

MagoBlue its not because I say you need to learn that I am being arrogant and I quote myself “like you said you may need to deepen your knowledge of how to program. This can be done with looking at the platformer tutorial.”

Wasnt I trying to help you in the first place? If you feel diminished by programmers its not my personal problem here. This tutorial has been here for months and I did not received any inputs until yesterday, I really thought it was good enough for what it was !

For the WorldSpawnPoint component or class, its an empty class that you add as a component to a gameobject. You can then have multiple spawning behaviour by declaring different SpawnPoint class and only checking if the component is available. You could also put parameters inside this empty class so the actual spawing occur with parameters set by the game designer.

for example this is my world spawn point class, and it is this class that spawn the actors on start of the game. The Editor class described in the actual tutorial is only for representing the spawn point in the editor, sorry for the confusion, so on with the code :

@script AddComponentMenu("Lume/Spawnpoint")

public var ActorPrefab:String = "Aki";
public var IsMainActor:boolean = false;

function Start()
{
	var actor:GameObject = gameObject.Instantiate(Resources.Load(ActorPrefab, GameObject));
	if(actor == null)
	{
		Debug.LogError("World Spawn Point could not instantiate actor : " + ActorPrefab);
	}
	else
	{
		actor.transform.position = transform.position;
		actor.transform.rotation = transform.rotation;
		
		if(IsMainActor)
		{
			Debug.Log("Set Main actor to " + ActorPrefab);
			//If this is main actor register with the AdventureModeManager
			LumeManager.instance.AdventureManager.SetAdventureModeActor(actor);
		}
	}
}

What I am acheiving here is loading a dynamic 3d object and then registering it to my custom adventure manager. In this manager I move the player around when input is made with mouse by clicking on the world.

I have 2 variables, one that set the actor by its ressource name, so a game designer can spawn say a troll, an elf, or the mighty connan if its defined in your resource folders. (check dynamic resource loading hre :x9productions.com the second variable IsMainActor says it all, if it is the main actor, this is the 3dmodel we need to register to the custom Adventure manager. Now if you have any other questions please feel at home to ask them and sorry if my tutorial was disappointing to you, my goal here was to pass on some knowledge.

There, I added a more in depth explanation of the mechanics. Let me know if something is still not right will ya :slight_smile:

Thanks Hot for clarifying things.

There’s a lot to take in here, so I’ll do some heavy studying tonight.
Thanks again.