Tag Info

Hot answers tagged

2

You can split this into two stages: Firstly generate some pinecones with such minimum distance between them that you need: On second stage add some pinecones next to those placed already: That way you will have have some single pinecones and some pinecones clumps, but all of those will be separated well apart. You can tweak 1st stage to use slightly ...


2

Simple Answer Use a class to load the original prefab from Resources.Load(string prefabPath, typeof(GameObject)); Store this returned prefab into a resource pool class by path key. For instance: Dictionary<string, GameObject> prefabLookup; You can then grab the original prefab anytime you need it. Use a helper method to automatically load at ...


2

You need to enable some kind of z-buffering: first render unobstructed units, then buildings, then units that are obstructed (complete or just partially) by buildings and then the ground. If you render them in this order make sure no pixel is overwritten: do not draw over a pixel that has already been drawn, else only the terrain will render. Flush the ...


1

Personally, I use a spin on the first option you listed. When checking if A collides with B, however, a series of disqualifiers (or a singular disqualifier) can be used to reduce the computation required for each iteration of your collision checker. For example: if((b.y >= a.y && b.y <= (a.y + a.h)) || ((b.y+b.h) >= a.y && (b.y+b.h) ...


1

It would be better to add a bool variable into your Script and then toggle it on/off. var object1Script = object1.GetComponent<MyScript>(); var object2Script = object2.GetComponent<MyScript>(); object1Script.enabled = toggle; object2Script.enabled = !toggle;


1

I am not quite sure what you are not understanding here, but I attempt to answer your question anyway. I am not quite getting what that does or what purpose it serves. In cases where you do not fill in the fields in the inspector (which requires them to be public), you need to find the instances of the needed components in code. The ...


1

Your TryToCreateNewMiner function can call it again. If your RandomPercent calculator keeps returning true, the callstack gets deeper and deeper. TryToCreateNewMiner->Miner->StartDigging->TryToCreateNewMiner


1

1) You don't need to calculate the visible objects in a single frame, you may use a bit bigger viewport, and calcultate only 500 objects per frame, if you have 20000 objects and your framerate is 50fps, in 40 frames you will have the right list, and it will take 0.8 secs 2) if your objects are not very complex or are static, sometimes is faster to put them ...


1

There's many ways to solve this. One way is, yes, to keep the resources attached to the game objects. Each game object would store a handle to its material and its mesh(es). Another approach is to keep a separate hierarchy/list of scene nodes. Each game object would just hold a reference to the scene node that represents the object visually. The scene node ...


1

In modern OpenGL you can almost totally seperate rendered object from each other, using different vaos and shader programs. And even the implementation of one object can be separated into many abstraction layers. For example, if you want to implement a terrain, you could define a TerrainMesh whose constructor creates the vertices and indices for the ...



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