Tag Info

Hot answers tagged

24

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.


17

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, ...


7

If you only have a few gameobjects it doesn't really matter. But if you are planning support for lots of gameobjects, I suggest you take at look at the following question: Game engine and data driven design And continue to read the following article (originally printed in Game Developer): Data-Oriented Design (Or Why You Might Be Shooting Yourself in The ...


6

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 ...


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

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 ...


5

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 = ...


4

IMHO: If you are programming some real-time application, you should avoid recursion if it's possible. Recursion has to push and pull curent context and it's slowing down your app. It's also more memory complex. Of course if you have just few objects, it's not so dramatic. But when you will add more and more objects in future, it will be slower and slower. ...


4

Recursion and depth-first traversal are not the same thing. This is also not about the merits of scene graph versus lists of components or whatever. It's also more of a general computer science issue than it is a gamedev issue. Bummzack's comment about how wasteful it is to create a whole new list is extremely important. You need to traverse your tree ...


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() { ...


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.


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

Your best luck is to learn some matrix math. You should have some kind of scene graph that establishes the character as a child node of the boat. It then would store it's position relative to the boat. The boat would have a transformation matrix, you apply that to the child nodes, and the child nodes could stack some more transformations on the matrix ...


3

Collision events will only be detected under specific circumstances. Each collider can be considered to have these relevant properties: Is a RigidBody (or RigidBody2D) attached to it's GameObject, if not it is considered Static. If it has a RigidBody, is it marked Kinematic? Is the Collider marked Trigger? The circumstances under which collisions are ...


3

These are not the same. Resources.Load is going to create a new uninstantiated GameObject. This means your first example is going to create a new game object, then set that object equal to the new game object created by Resources.Load. That means two objects are going to be created, an empty game object added to the scene (from the new GameObject() call) ...


2

Go with linear, as it's easier to follow and iterate through objects than it does adding more to a stack and unwind. If the order in which the gameobjects are updated is not very crucial to the behavior and interaction between, linearly updating would be all you'd need. It all depends on how strongly coupled the objects' behaviors are on each other.


2

Each object should own its own properties. If other objects need to know those properties, let them query for them. Your sprites probably don't have an intrinsic position, and they don't know how to get a position to be rendered because they may have to get that information from more than just Actors. So, you need a class that mediates between them. You ...


2

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


2

It sounds like you want to extend the Unity editor. Looks like you can use the Handles class to create custom handles for your objects too.


2

Using decorators is not a good idea in this case, because you also want to un-equip items. When you wrap decorators in decorators in decorators and then want to remove a specific one inside that stack, it's a quite messy operation (especially because an object shouldn't be aware that an object it uses is just a decorator wrapping something else). What you ...


2

Your idea of using a static method is probably the way to go. Give Enemy a constructor with all the values as parameters, then use static methods to make it easy to call it. Generally, you extend a class so you can override its methods. Suppose Enemy has a goToPoint method that moves the object in a straight line at a constant speed. You want a Ninja to ...


2

If you want to see all the objects that are using a specific script, there are a few ways you can do that. Iterate through all the game objects and return a list at will. You can find all the objects of a certain type with: (Where myComponent is the type of component you're interested in: myComponent[] myComponents = ...


2

This is a pretty big question and I think you might be better served by asking each part separately. That said, two of your points (viewport and collision) are essentially about accessing "nearby" objects efficiently. The way to do this is to use some kind of spatial data structure (aka spatial index). The simplest one is to have a two-dimensional array ...


2

You can do this using plain mouseup/down tests and raycasting, and the same pattern applies to many other situations, like marquee selection. // Call this inside an Update method. void HandleDragging() { const int mouseButton = 0; // button values are 0=left,1=right,2=middle if(_isDragging) // Leading underscore denotes private member variables ...


2

You could use two approaches here; directly calling a function when the object is destroyed, or handling an array of objects yourself. In the first approach, you could take advantage of the OnDestroy function that belongs to MonoBehaviour. using UnityEngine; using System.Collections; public class YourClass : MonoBehaviour { void OnDestroy() { ...


2

Well I'd like to comment on the question but I don't have 50 rep. Anyways: If we knew why you were doing this (specifically) then we might be able to help. To know when to stop moving the object, you'll need a condition as such: int maxProgress = 100; //the value at which the progress is full if (progress > maxProgress) //if it is full { var cube = ...


2

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 ...


2

if you want to obtain the object owner of the collider instead of the hit point (that can be anywhere over the collider) simply use this code instead of hit.point: cameraDestination = hit.collider.gameObject.transform.position; The camera will center on the gameobject that owns the collider. If the position of the object is also the "visual" center you ...


1

Working from the framework you have now, can GamePlayState simply expose a public getPlayerCharacter() method? Then you can cast your IGameObject to a GamePlayState and call it. Something a bit like... GamePlayState currentState = stateSystem.getGameObject("Gameplay") as GamePlayState; if(currentState != null) PlayerCharacter playerCharacter = ...


1

Rigidbodies awake when any force is applied to them. If you had a pool game and all the balls are sleeping and you would hit them with another ball, they would all wake up. I guess there is some minimal jittering going on that keeps your rigidbodies alive. There are a lot of parameters that can have an impact on this, but personally I would first and ...



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