Questions tagged [gameobject]

A game object is any object in a game that the player can see and/or interact with. The player object, power ups, enemies, platforms, walls, weapons (if collision detection is considered) and projectiles are all game objects.

Filter by
Sorted by
Tagged with
1 vote
1 answer
1k views

How to assign game object references to a class instance created at runtime?

I'm creating a game where I have an Entity class that contains basic entity info (pos, health,..) and some functions. Enemies and Player later on inherit from this class. ...
MSKL's user avatar
  • 133
1 vote
1 answer
1k views

Using StartCoroutine() and WaitForSeconds()

I am trying to perform two operations. First I want to increase the size of a GameObject and then delay for 0.1s before returning it back to its original size. However, when I try using StartCoroutine(...
M.Ahmed's user avatar
  • 11
12 votes
5 answers
47k views

How to store references to scene objects in prefabs?

i am instantiating a few game objects in my scene using prefabs and i would like to attach a script to some of them to do something at a certain time but for that i need to reference to scene objects ...
Mohit Saxena's user avatar
3 votes
1 answer
672 views

Different objects interacting based on type

Many many thanks to anyone who chooses to take the time to read through this all and offer any advice. I'm writing a game in which multiple different kinds of Objects move around a grid-based board ...
CaptainTid's user avatar
1 vote
1 answer
95 views

Method causes OutOfMemory error

If a GameObject in my game has a special ability it triggers it, but I want all the special GameObjects that this GameObject affects to also trigger their abilities, for example if a bomb hits some ...
Milen Pivchev's user avatar
1 vote
1 answer
1k views

Unity3d select empty gameobjects in scene

I have a pathing system that I am creating in Unity. When you add nodes to denote the path, I create a empty GameObject and render it in OnGUI as a square. The problem that I have is clicking on the ...
Hector Llanos's user avatar
0 votes
2 answers
897 views

Is it more efficient to add scripts to each GameObject or to a single parent object?

Does a C# script added to a parent object work more efficiently and effectively (in terms of both memory and performance) on all objects, in my case lighting, or adding script components to each ...
Mark Henderson's user avatar
0 votes
1 answer
2k views

Trying to get an object to move in the mouse direction XNA C#

Right, so in my Player class where I call the object I got an if statement which gets the coordinates for the mouse ...
Pavvel's user avatar
  • 29
6 votes
2 answers
4k views

Best way to keep track of game objects

I'm not exactly sure how I should ask this question, and so the title may be misleading - I am not asking if I should use a list or a stack or a vector or a queue - but how I should go about keeping ...
Daniel Martin's user avatar
2 votes
1 answer
1k views

Storing transformations in game objects. (GLM, C++)

I'm currently writing a game engine from scratch for learning purposes. I just started implementing transformations. I know how they work in general but I'm not sure how to implement them efficiently ...
Tin Svagelj's user avatar
2 votes
0 answers
94 views

What is the purpose of `gameObject` property inside `GameObject` class? [closed]

There is this property defined in the GameObject class: ...
Sinatr's user avatar
  • 131
1 vote
3 answers
13k views

How to check if a game object is inside another gameobject

My idea is that there is a plane which is more of a border at top of the screen and if a game object has no more space to fall and it collides with something while it is in that border, the game ends. ...
Milen Pivchev's user avatar
1 vote
2 answers
475 views

Trying to better understand Unity gameobjects

New to Unity, but develop in C# normally. I can't seem to get how / why / where to grab certain elements. For simplicity, I have a top-level game object, say a cube. I add a sphere to the scene as ...
DRapp's user avatar
  • 135
0 votes
1 answer
331 views

C++: passing gameobject as a parameter and then into vector

firstly iam used to java and new to c++ so maybe this will looks a noob's question i will explain this and give a pseudo code and then c++ just so you can understand me i have a player class which ...
younlok's user avatar
  • 19
0 votes
2 answers
207 views

Why is there a gameObject inside a GameObject [duplicate]

In order to manipulate a game object via script in Unity I need to access the gameObject inside the main GameObject. Why is it ...
BanksySan's user avatar
  • 200
0 votes
1 answer
6k views

How can I edit the components of an instantiated prefab?

Is it possible to edit one or more components of an instantiated prefab ? For example if you instantiated five cube prefabs. Is it possible to reference each of the cube prefab and change a value ...
JekasG's user avatar
  • 407
0 votes
1 answer
169 views

How can I toggle enabled on a specific script within an object in Unity?

I have the CarController script inside my car GameObject. I need to set it to disabled at the start so the countdown timer can start the race. I thought I knew how to do it but once again I have ...
Big T Larrity's user avatar