Skip to main content
5 votes

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; This ...
DMGregory's user avatar
  • 141k
5 votes

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" ...
Philipp's user avatar
  • 123k
4 votes
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 ...
Casey's user avatar
  • 2,095
4 votes

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 ...
sjoerd216's user avatar
  • 219
4 votes
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 ...
Mario's user avatar
  • 8,537
3 votes
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: ...
Sisyphe's user avatar
  • 66
3 votes
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 ...
jnelsis's user avatar
  • 61
3 votes

Godot: Spawn an object in 3D

This is your PackedScene: const FlareScene := preload("res://flare.tscn") You instance it like this: ...
Theraot's user avatar
  • 28.3k
2 votes
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 ...
Philipp's user avatar
  • 123k
2 votes
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, ...
DMGregory's user avatar
  • 141k
2 votes

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

First, you should combine this information: ...
Draco18s no longer trusts SE's user avatar
2 votes

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 ...
Goose's user avatar
  • 123
2 votes
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 ...
Shuvro Sarkar's user avatar
2 votes

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: ...
Pikalek's user avatar
  • 13.4k
2 votes
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 ...
Philipp's user avatar
  • 123k
2 votes
Accepted

Spawn Array of GameObjects to Array of Transforms

Would simple for loop work? ...
sorko's user avatar
  • 61
1 vote
Accepted

How to Spawn GameObjects at Random Positions in Unity?

Your problem is in your for loop : for (int i = 0; 1 < numRunTry; i++) 1 is always less than numRunTry so loop never ends. Probably a typo and you meant ...
Acme Nerd Games's user avatar
1 vote
Accepted

Recycling bullets versus spawning them on demand

The method that most games use is a variant on 1 where there are multiple instances which get recycled. How many you pool depends on your game. This way the CPU performance doesn't vary as more ...
ratchet freak's user avatar
1 vote

Unity 3D mirror, sync player spawn name

welcome to the GameDev Stack Exchange. It looks like your code currently only runs server side which is pretty normal for most projects when initially creating players and setting up the scene. This ...
Benjamin Danger Johnson's user avatar
1 vote

Unity 3D mirror, sync player spawn name

You can use a syncVar for the player name. [SyncVar] public string playerName; You have to set the playerName on the server. The clients will automatically get ...
kyu's user avatar
  • 35
1 vote

Tetris block kinematic rigidbodies pass through one another with Transform.Translate

From your screenshot I see that you are using kinematic Rigidbodies. Kinematic Rigidbodies don't behave like Rigidbodies in most ways. They ignore forces, as I assume you've already noticed since you ...
Kevin's user avatar
  • 7,029
1 vote
Accepted

Increasing spawn difficulty

The problem is that when you call InvokeRepeating, the current value of nextSpawnTime gets copied to the Unity coroutine system. ...
Philipp's user avatar
  • 123k
1 vote
Accepted

How to manage network spawning?

You can do something in-between. For example, players request the full state when they reconnect, or if it's determined that something is wrong. During normal gameplay, you just send the relevant ...
Mars's user avatar
  • 541
1 vote
Accepted

How can I add a delay to my enemy spawning in Greenfoot?

Let's walk through this code, pretending that nanoTime = 0 at the start for simplicity. We initialize beginTime = 0 and ...
DMGregory's user avatar
  • 141k
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 ...
monty's user avatar
  • 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.
Coldsteel48's user avatar
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: I ...
Boneco Sinforoso's user avatar
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 ...
Sean Carey's user avatar
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 ...
DMGregory's user avatar
  • 141k

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