(Unity) Useful uScript Graphs

Spawn gameobjects over time at a particular location

clone the gameobjects

This graph will allow us to create a new “spawn_over_time” component. If we place it on an object…

And customize its properties

  • “delay_sec” controls how often a new gameobject is spawned.
  • “gameobject_to_clone” controls which gameobject gets spawned (we need to drag something in to this slot)

We can then move whatever gameobject has this component (let’s call it the “spawner”) around, and have it spawn new gameobjects there.

Change scene upon touch

Useful for advancing to a new level, ending the game, etc.

The above graph creates a new component that can be used to change the current scene if something touches the gameobject–

In this case, the red cube gameobject has the new component, and it is configured (on the right) to send us to the “game_over” scene, but only if the “player” gameobject touches it–

Note that, for us to get the “Triggered By” output, we need to enable it in the “properties” pane, as shown below.

Also note that whatever gameobject uses this component needs to have a Collider component that is set to “Is Trigger” mode, as shown in the gif below–

Updated: