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 ...
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" ...
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 ...
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 ...
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 ...
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:
...
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 ...
3
votes
Godot: Spawn an object in 3D
This is your PackedScene:
const FlareScene := preload("res://flare.tscn")
You instance it like this:
...
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 ...
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, ...
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:
...
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 ...
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 ...
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:
...
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 ...
2
votes
Accepted
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
...
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 ...
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 ...
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 ...
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 ...
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. ...
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 ...
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 ...
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 ...
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.
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
spawning × 85unity × 49
c# × 24
random × 10
2d × 6
game-design × 5
unreal-4 × 5
c++ × 4
game-mechanics × 4
gameobject × 4
java × 3
architecture × 3
gamemaker × 3
unity-networking × 3
blueprints × 3
physics × 2
libgdx × 2
camera × 2
networking × 2
multiplayer × 2
procedural-generation × 2
godot × 2
pygame × 2
unreal × 2
platformer × 2