# Tag Info

Accepted

### Set a 'chance to spawn' for each GameObject in an array

Here's one way to do it, using a custom struct to store object-weight pairs: ...
• 135k

### How to synchronize the speed of spawned object and spawning time interval?

This is a simple application of the distance-velocity-time triangle: (Image via BBC "Bitesize Maths") float timeBetweenSpawns = spaceBetweenBalls/ballSpeed; ...
• 135k

### how do i NOT let this object spawn at a certain area?

A simple solution which covers a wide variety of circumstances which could invalidate spawn locations can be to simply check if the randomly generated position is within a "forbidden zone" ...
• 120k

### How to make sure that the set of randomly spawning obstacles is passable?

If the blob has a constant vertical speed, and you know the horizontal speed of the incomming objects, you can use those variables to calculate the minimum and maximum angles the blob can travel to at ...
• 219
Accepted

### Spawn rates and variable time steps

I'd go with something like this (pseudo-code): ...
• 16.3k
Accepted

### How to implement arcade-style spawning?

Don't trigger based on the camera's position. Trigger based on the player's. Once the player enters the trigger you spawn the enemies just outside the edges of the camera's view. Since the camera ...
• 2,045
Accepted

### Godot: Spawn an object in 3D

Spawning nodes dynamically works the same, whether it's 2D or 3D, and you kind of were on the correct track: Load the scene as a template. Instantiate said scene template as a new node. Add the new ...
• 8,497
Accepted

### Instantiate object with spawn time?

I would suggest creating a coroutine which takes three arguments, one for the gameobject which is to be instantiated, another for the number of times it should be instantiated, and the final parameter ...
• 61

### How to spawn multiple objects in the same frame?

You could use a for loop and a random integer between 1 and 4. ...
• 1,260
Accepted

### Spawn a prefab at random y position with different gap between prefabs

In your update, you describe placing the walls on either side of a room. From your description and diagram, you intend to use random heights for the walls. Instead, I would recommend randomly deciding ...
• 5,273
Accepted

### Ensure that random enemies don't spawn just near the player

The simplest system I can think of consists in testing the position of the new enemy before your screen.blit(), like so: ...
• 66

### Godot: Spawn an object in 3D

This is your PackedScene: const FlareScene := preload("res://flare.tscn") You instance it like this: ...
• 27.2k

### Unity2D: How to destroy spawned object once it exit out of camera's view?

OnBecameVisible and its counterpart has a few gotchas. It works only if the gameobject has geometry. The editor view also triggers these events. You might want to ...
• 271
Accepted

### How do open world games handle efficiently enemy respawn?

When you need to persist the state of a chunk but you are running out of memory, consider persisting it to the hard drive. If your game has enough complexity and data to warrant it, you might want to ...
• 120k
Accepted

### How do I respawn a prefab that matches the name of the game object I just destroyed?

Edit: whoops! I had the idea that I wanted the prefab of the object itself to remember which prefab it's spawning from, but neglected a wrinkle of prefab spawning: when you spawn a copy of an object, ...
• 135k

### How do I respawn a prefab that matches the name of the game object I just destroyed?

First, you should combine this information: ...

### Unity: Player Gets Stuck Between Tiles

In many situations, depending on how collision works in your game, you can use the Sphere Colliders or Capsule Colliders instead of the box Colliders. This will let the character slider over Box ...
• 121
Accepted

### How can I spawn items based on probabilities?

There are different ways of doing this. Here I am giving two ways of getting a weighted game object. The first one is easy but not a good practice and has a lot of issues. I have commented on the code ...

### How can I spawn items based on probabilities?

In genetic programming, this is called the roulette selection function/algorithm. Here's one way to implement it: ...
• 12.4k
Accepted

### Spawn Array of GameObjects to Array of Transforms

Would simple for loop work? ...
• 61
Accepted

### Random Spawning Traffic at Pace Fitting "Frogger"-style Gameplay

First of all, I see a big problem with your code. You are potentially spawining a car each Update. That means you are making the spawn frequency dependent on the ...
• 120k
1 vote

### My GameObject keeps spawning when it shouldn't

What happens: Your object state is (x = -10, floorsSpawned = 1) You object moves to the limit of the first if (state: x = -18.1, floorsSpawned = 1) and the first object is instantiated (floorsSpawned ...
• 384
1 vote
Accepted

### How can a variable have two values at the same time?

Begin play called before you are setting the variable. On dynamically spawned actors begin play will be called instantly before any other bp node will be executed.
• 818
1 vote
Accepted

### Actor does not perform action when spawned?

Go to the NPC blueprint at the top of the screen, click Class Defaults, search for the Auto Possess AI option on the Pawn menu and select the Placed in World or Spawned option. Image to facilitate: ...
1 vote
Accepted

### How to Destroy an Instance of a Prefab Without Removing the Prefab?

Your SpawnObstacles script is referencing a gameObject in the scene, rather than an actual prefab. To create a prefab, drag and drop your Obstacles object to your assets folder. Then make sure that ...
• 694
1 vote
Accepted

### Rotate object to closest clone?

I notice your script looks for enemies only inside a distance of 20 units. So we don't need to scan the whole scene for enemies using FindGameObjectWithTag, we can ...
• 135k
1 vote

### Make enemy disappear after spawn

You can call Destroy with a 2nd parameter indicating the delay before the destroy occurs : ...
• 2,949
1 vote

### Display image a couple seconds after an enemy spawns?

Well, all those co-routines and waiting for some seconds are nice but, why not just use Invoke() for this purpose as well? ...
• 3,126
1 vote

### Game maker studio 2 Random spawn locations are not random

I am almost certain that this is a setting for debugging purposes. Debugging randomness is a pain so sometimes engines do a pseudo randomness with some sort of seed so that you can have consistency ...

Only top scored, non community-wiki answers of a minimum length are eligible