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.

learn more… | top users | synonyms

1
vote
1answer
39 views

How do you play more than one animation at a time in unity

I am trying to have 2 animations on one GameObject and i want them to play at the same time. I have been looking all over and messing around with the animator controller but i cant get it working.
0
votes
2answers
152 views

Where should I save game object's attributes (hp, score) in Swift?

Scenario: I have a game with several game objects on screen. Each can have different score and hitpoints. When I use collision detection for cannonball vs. ship (example) I need to know which ship is ...
1
vote
4answers
52 views

How to find nearest gameobject on one side

Here is an example: The left enemy robot is closer than the right enemy robot, but I want the character to attack the robot that is closest to him on his right side. I can't use Physic.SphereCast ...
1
vote
2answers
164 views

Determine facing direction mecanim 2d movement

I'm using this script to move my character in my 2d world: public float speed; //Movementspeed public Rigidbody2D rbody; Animator anim; void Start () { rbody = GetComponentInChildren<...
0
votes
1answer
667 views

Game object position issue in unity3d

I have a set of objects placed on the same layer where all the objects are invisible except one. When I drag an object into a selected area, the current dragged object gets destroyed, and the object ...
1
vote
1answer
339 views

Structure gameobjects and call events

I'm working on a 2D tile based game in which the player interacts with other game objects (chests, AI, Doors, Houses etc...). The entire map will be stored in a file which I can read. When loading the ...
0
votes
2answers
48 views

snap an object to another object?

so I have some walls which are cubes stretched along a direction.and I have some windows and doors that are suppose to snap to a wall and don't let go until the desired location is out of the snapping ...
0
votes
3answers
300 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. ...
0
votes
1answer
59 views

Blender assets management and workflow for Unity project

I'm trying to decide how to manage my 3D assets, and even how I should construct a world for my game. I should maybe explain, my game is basically a single explorable world set in a school. It's ...
3
votes
1answer
617 views

Component-based object, traversal?

I'm working on a small C++ component based game engine, as such... Object Foo might extend GameObject and x number of component interfaces, like Renderable and/or Physical. So let's assume that Foo ...
0
votes
1answer
90 views

Collision between UI element and GameObject

When I first started to develop in Unity I followed the Unity Tutorial for the Space Shooter 2D game and used the knowledge from that to create something myself. Looking at it now it may not have been ...
0
votes
1answer
23 views

How to get which gameobject the mouse is over in Unity?

So I'm working on a simple drag-n-drop based trading card game for my own amusement. There is a card inspector included. What I want to achieve is to change values in the inspector (which has its ...
0
votes
2answers
40 views

Roatating a Game Object downward

In my game I have a rocket which is traveling horizontally across the screen. What I am trying to do is when the player runs out of fuel, the rockets engine stops (already coded) and then the rocket ...
0
votes
1answer
50 views

Simplifying Object Factory

I'm making a game for Android using Libgdx with Android Studio in Java. In my game, I have a class called ObjectFactory which has a method createGameObject(int objectType) which receives an integer ...
0
votes
1answer
78 views

Unity - Hide GameObject that is behind UI

I have the following example: How can I prevent the part of the sprite that is highlighted in red and is behind the UI from being displayed on the camera, but having the background image still ...
0
votes
0answers
10 views

MeshRenderer.sharedMaterial does not change twice

Hi I was changing material from an object and using this code that's working well: MeshRenderer renderer = tile.GetComponent<MeshRenderer>(); renderer.sharedMaterial = Resources.Load<...
0
votes
2answers
47 views

How to get obstacles to spawn randomly in x position in an infinite runner? 2D

I'm trying to make two obstacles that are different sized to come in a random order in one straight line where the player is going. Doesn't have to be with object pooling. It seems that the ...
3
votes
2answers
101 views

How do I find the location of a GameObject in C#

I'm making an elevator script. Essentially I'm wanting to find the difference between two empty objects so that I can move the elevator between them. To be able to do this, I need to be able to get ...
0
votes
1answer
52 views

Unity: Assign GameObject to Class that hasn't been yet instantiated

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. Public class Entity { ...
1
vote
1answer
37 views

Help with open and close UI Menu on background mouse click

I am trying to make a point and click game in unity 5.2.2. My problem is that I need to have a UI menu to open, when the player clicks with the left mouse button on the background sprite, and it ...
0
votes
0answers
10 views

Adding calls to an Entities update function

So I am trying to add a property to my entity function then in order for it to update I need to call it within the entity's update function so this is how I create the entity var sprite = ...
0
votes
1answer
57 views

How to use objects with different attribute values in Swift?

I think this is a really basic question and to make it easier to understand what I do not understand, I use the following scenario. Scenario: I have two or more ships in my game. They should have ...
2
votes
3answers
183 views

Game Object is Instantiating on same position

I am working on a small project . But now I have come across a problem . The problem is the prefab is instantiating on the same position . I want to instantiate a box end to end . The basic set up is ...
4
votes
1answer
154 views

Does distant and large objects use up a lot CPU usage?

Okay I'm new to Unity, and I'm making a space sim pc game. You know, space is huge, light years of distance between stars. Even if I set 1 AU (150,000,000 KM) as 1 unit, 1 light year will be 63,000 ...
5
votes
3answers
216 views

How to handle GameObjects that have been destroyed but are still held by others?

I'm developing my own game engine in C++ as a learning exercise. I have employed a fairly standard method of handling destroyed GameObjects: Mark them as destroyed Have the scene delete destroyed ...
3
votes
1answer
70 views

Performance differences: one empty GameObject with multiple child objects vs. single GameObject formed by pre-merging the former child objects

Imagine a robot game where robots are made of pre-built blocks. Therefore, each block is a separate GameObject, with one mesh each. I am trying to understand the conceptual differences behind the ...
0
votes
2answers
250 views

How to check if an GameObject exists in Unity2D? (Javascript)

Im making an AI that checks if the player exists or not. How do I check if a certain object exists and put it in a boolean variable?
1
vote
1answer
78 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 ...
4
votes
1answer
431 views

Can instantiated objects have different material/texture?

While I have some experience with simple 2D games, I am new to more process-demanding 3D games. One basic question that has been concerning me recently and for which I am having difficulties to find a ...
1
vote
1answer
115 views

Duplicate a Prefab as a separate asset in Unity 5.2 [duplicate]

I have a Asset which is a collectable object [Pickup] and I currently have eight in my scene, I'd like to duplicate this asset and use it to harm the player [Bad Pickup]. I decided to duplicate the ...
2
votes
1answer
764 views

best way to destroy an gameobject in unity

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the ...
2
votes
1answer
68 views

Assigning Objects when duplicated in the editor?

I'm wondering if there is a way to have an Object when duplicated in the editor assign a GameObject variable to the newly duplicated version of itself. Is there an option in Unity or do I have to code ...
0
votes
0answers
103 views

Unity 5 2d array for storing game objects and their data

I want to have a 2D array which has a number of rows relating to the number of game objects and 3 columns. I want each row to have the name of the game object and its position and velocity. Is this ...
1
vote
2answers
660 views

Set Parent to Instantiated Objects in Unity

i am having problem in attaching parent to the instantiated objects. I have attached the code below. please tell me where i am doing wrong. Thank you. public GameObject brick; public Transform ...
0
votes
2answers
122 views

Create a custom shape from a basic shape

Is it possible to create a custom shape by modifying one of the regular 3D objects in Unity3D 5.1? For an example: Make a cone from cylinder.
0
votes
1answer
378 views

Unity - SetActive() on GameObject dont works on child's objects

I have the following line of code: GameObject.Find("_obstacles").SetActive(false); It serves to leave an inactive object, but the children of this object are not getting with the same status. My ...
3
votes
1answer
107 views

Diversified Game Object List

Recently I started creating a game in java to hone my rusty java (I work primarily with cpp) and because I thought it to be a neat idea. To better illustrate the problem, let me explain a part of the ...
0
votes
1answer
77 views

Unity why do all gameobjects not dissapear from view when I switch cameras?

I am having trouble with camera switching. I have two cameras: "Camera1" and "Camera2". A "button script" attached to Camera1 allows a switch to Camera2. It also positions the cameras. There is a ...
2
votes
1answer
997 views

How to remove a component of an object in a script?

I want to remove a Sphere Mesh Renderer component from a certain gameobject. I want to do this in a script. How do I do it? I do not want to destroy the sphere itself, just the component
0
votes
0answers
468 views

Unity3D - Unable to attach script to GameObject prefab at runtime

I've got a script that manages a scene browser within my application where I'm hoping to generate a new button instance for each scene found. I've put together a button that I've made into a prefab ...
-1
votes
2answers
2k views

How to enable and disable scripts on a Game Object?

This worked briefly yesterday, I believe I did something to mess this up. All my inputs that I put in are correct; therefor, it must be the code. I want to switch players. While the red cube's script ...
0
votes
3answers
805 views

Unity 2D - Instantiate a GameObject and scale it every second

I want to make a bomb-like game object, that when instantiated, takes 2 seconds to charge, and then some other event triggers. The problem is I can't make it scale smoothly for 2 seconds, and then ...
4
votes
2answers
5k views

How can I create an array of GameObjects?

I need to add one assest multiple times in my scene similar to the blender array tool and I was wondering what is the best way to do this because adding each asset individually and setting there ...
1
vote
2answers
500 views

What's the difference between Destroy() and SetActive(false)?

I read about both methods in Unity and wanted to ask about which was the best in efficiency : destroying the object or deactivating it. What is the performance difference?
4
votes
4answers
2k views

What are the differences between using “GetComponent<Transform>()” and this.transform?

I've been reading some example codes and working on my own stuff in Unity. I've been seeing a lot of GetComponent, and often this will be done for the transform: Transform _transform = GetComponent&...
0
votes
2answers
85 views

Can we create same name class for different objects in unity?

I have four similar objects in my game. As they are all similar therefore I have created a single script that defines mash for all of them. The script that defines mash for these objects uses a ...
0
votes
2answers
374 views

collision in different layer

I have a game object called game object 1 on screen. It holds an image called red . when i drag an image called "animal" on a game object 1 collision happening fine and destroys the "animal" in same ...
2
votes
2answers
395 views

How to apply a script to multiple Objects in Unity?

In Unity, I've almost 200 or more objects. I wish to apply single script to all those objects. I'm a beginner & learning scripts in Unity. Edit: At the time of editing the scene itself.
1
vote
1answer
108 views

Unity3D - GameObject as a static function

Newbie Unity3D/C# developer here. I've tried learning Unity3D during my May/June college vacation and came across a problem:Code 1: CameraObj returnVoid; void Start () { returnVoid = GameObject....
3
votes
4answers
650 views

How to enter a level when touching an object

I am working on a project in Unity 4.6.1f1 and I was wondering how can I make a cube touch another cube to go to the next level (the image below)? ! EDIT: I made a script and put it on the purple ...