25

I believe Prop ( See: http://en.wikipedia.org/wiki/Theatrical_property and https://developer.valvesoftware.com/wiki/Prop_Types_Overview ) is commonly used. There are less ambiguous alternatives, for example Blizzard uses the word Doodad.


18

I would use the word Doodad for those environmental things as it's a standard. When editing in both Titan Quest and StarCraft's Map Editor, they're referred to as Doodads. http://starcraft.wikia.com/wiki/Galaxy_Map_Editor#Terrain I usually refer to objects an Actor can interact with as Props, just as if they were on a stage. Actors use Props to do actions, ...


17

In the editor, prefabs can only reference other prefabs. Prefabs are supposed to be shared between scenes. That means they can't rely on the object being present in every scene. If you need them to reference something in the scene, you need to get that reference at runtime. There are several ways to do that. Attach the reference to the object which ...


12

You only need to destroy the GameObject. By destroying the GameObject (Destroy(this.gameObject);), you also destroy the script (Destroy(this)) automatically. Destroying the script simply removes the component from the GameObject. Destroying the GameObject removes all of its components, and the GameObject itself. But there is an issue with your code. ...


10

since you admittedly don't have much experience with 3D and (presumably) OpenGL, I'll give you a "bird's eye" overview of the process. I'll do my considerations about OpenGL, but the basic reasoning yields for other APIs too. When you render something with a modern version of OpenGL you create objects that will reside into the GPU memory, and then mostly ...


8

As requested, one possible solution (with some flaws) is to use raycasting: Attaching a (C#) Script similar to this to the GameObject from which you want to check visibility would work: if(renderer.isVisible) //Check if Camera is turned towards the GameObject first { RaycastHit hit; // Calculate Ray direction Vector3 direction = Camera.main....


8

You're assigning the value of money to the print return value, not the actual int value being returned. money=print(PlayerPrefs.GetInt("Money")); Should be money=PlayerPrefs.GetInt("Money");


7

If anything, the first option might be better for cache misses since generally you'll be iterating through, say, all the Renderable components at once. Just copy the data you need into that component to avoid cache misses due to looking up data. But it seems like you're suffering from design paralysis. Do you actually have a working game yet? Are the ...


7

Destroying the object gets rid of it completely. You cannot get it back. It is gone. Deactivating it just disables it; everything is still there, it just does nothing. Therefore, if you want to reuse the object, you can deactivate it, but if you will never use it again, you should destroy it (and get back its memory).


7

At the moment I'm using std::shared_ptr to support multiple ownership of GameObjects so that they are held by both the scene and any other GameObjects within the game Don't do that. shared_ptr is often the wrong tool for the job, and that certainly applies here. Remember that smart pointers are for managing ownership; shared_ptr is about sharing ownership. ...


6

Your question seems indeed a bit confusing. I assume you are asking about the problem, how some specific code piece (e.g. the function responsible for firing a bullet within the mob unit) should get to the information about "how to fire the bullet" and "what bullet type" and so on? Here are some solutions: Just use globals and get over it ;) In gaming ...


6

The best way to do this depends on a few things. I'm going to assume the following - if any of these are incorrect, please let me know and I'll update my answer: You want the closest enemy that is anywhere to the right of the player within a certain range, even if it is at a different height You want true distance, not just the one that is closest in ...


5

Vectors are dynamically sized (usually) random access containers. They facilitate constant time look ups to any location within the array, and better yet, their direct storage is contiguous. The biggest (and its a big one) downside to vectors is the performance hit when they need to grow. Vectors typically allocate a certain capacity, and this capacity is ...


5

Depending on your exact needs, another possible solution would be to do a test render where you set different objects to different colors and then check for that color in the test render. However this would only be useful in pretty obscure situations; in the majority of situations I would use raycasting. I'm just dropping in this different answer for ...


5

You can Destroy the component. Be careful about which object you destroy, though. If you pass a GameObject to Destroy, you will destroy the entire thing. To destroy the component, you must pass a reference to that component specifically. //example: destroys the MeshRenderer attached to this GameObject var sphereMesh = GetComponent(MeshRenderer); Destroy(...


5

Passing through the gameObject name to a method, then using GameObject.Find to find it again by its name, is bad practice, and inefficient. GameObject.Find is an expensive operation. Rather do something like this... void Update () { if(Input.GetButtonDown("Fire1")){ // detect left mouse click ray = Camera.main.ScreenPointToRay(Input....


5

Sorry, but that's not going to work. ScriptableObjects are supposed to act as assets which can be reused between scenes. That means you can't and shouldn't make them dependent on objects which exist in only one scene. But what you can do instead is: Ugly workaround 1: Have the ScriptableObject find its object(s) at runtime. You can do that by tag, by name ...


5

I believe an option available to you is to use std smart pointers, more specifically the std::shared_ptr and std::weak_ptr. Typically, those pointers represent ownership. They also offer a ref-counting mechanism, and I think it's this feature that you're after. std::shared_ptrs hold a reference to a dynamically allocated object, a count of "hard" ...


4

Components should register themselves with the appropriate system. You could do this in the constructor/destructor, though I'd highly recommend some explicit OnCreate() and OnDestroy() methods or some such. You'd have something like so: void Renderable::OnCreate() { g_Renderer->RegisterRenderable(this); } void Renderable::OnDestroy() { g_Renderer-&...


4

Something which is part of the set is a "fixture", or "landscaping".


4

Your LevelCollider is attached to a Collider that is a trigger. That means it will not call OnCollisionEnter. It will call OnTriggerEnter. Try adding this to LevelCollider: void OnTriggerEnter(Collider other) { Application.LoadLevel("Level1"); } That should do ya!


4

Here are the steps for applying scripts to multiple objects. Step 1. Select all your objects from Hierarchy panel. Step 2. Then from Project panel drag & drop your script into Inspector panel.


4

You are using a button, which is an UI element. It is not supposed to be used on 3d objects in the game world. On 3d objects in game world you probably want to use IPointerClickHandler. They work like this: using UnityEngine; using UnityEngine.EventSystems; public class Clickable : MonoBehaviour, IPointerClickHandler { public void OnPointerClick( ...


4

For an instantaneous radius check, you can use the OverlapSphere method like so: Collider[] hits = Physics.OverlapSphere( explosionCenter, explosionRadius, layerMaskToCheck ); This gives you an array containing all colliders touched by the explosion's spherical volume. You can then iterate through that array to apply forces &...


4

You can specify layers that a camera should and should not render: https://docs.unity3d.com/Manual/Layers.html. Anything that should be rendered by one camera but not the other should be assigned to a different layer. You can do this through code by changing the gameObject.layer. Then, in a camera's Inspector, deselect that layer from the "Culling Mask" drop-...


4

Add to your music class a method like this: public static Music GetInstance() { // Optionally, you can create an instance here // if one isn't already present in the scene. return instance; } Then when you want to toggle the music, instead of referencing an object saved in a member variable, ask the music class which instance is current: var ...


4

The solution by DMGregory is a quick and dirty solution which works well for a single audio source. But in a more complex game you might have multiple audio sources which function as background music. You might also have other groups of audio sources you want to mute together. In that case you might want to use the cleaner solution using the Audio Mixer ...


3

I recommend your second option, adding/removing links. If option 1, using a particle system, is even possible, it is highly likely to be essentially reimplementing option 2 by twiddling the particle system from outside. You'll also likely have issues at the ends due to the particles being obviously different from the neighboring geometry. I've never seen a ...


3

What's wrong with just making it a global? Making a game is significantly more important and rewarding that adhering to academic purity. Just get the job done. That said, another option is to store a pointer to the owning State in the game object. It's wasteful if you're just using it to avoid having a single global pointer but it can be a boon if you ...


3

"Decoration" has always been the name I've given to non-interactive, non-collidable elements. When using flixel I would have level data defined by three separate layers Solid, Interactive and Decoration. Solid and Decoration would then be loaded into Tilemaps, both would be rendered but collision checks would only be made against Solid.


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