Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
23 views

How to get started in game development [on hold]

What are the basic requirements? What kinda tools will I need? What language should I learn? What game engine should I study?
0
votes
1answer
38 views

How to remove an element from the scene while keeping it in array?

I combined cube meshes to make a big one. I stored the info of every cube in an array within a list of chunk. Now i want to delete the cubes in the scene to only keep the combined result, but without ...
0
votes
3answers
73 views

Count the number of Vulnerable and Invulnerable crops

I have this code that counts how many GameObjects (crops) in the scene GameObject[] crops; and the code to get the health component of each crops ...
1
vote
2answers
79 views

Alternative for using game object/prefabs for level generator

I just finished the Unity Tutorial for creating a simple 2D roguelike Mobile Game. Now I wanted to make my level bigger; finding or creating my own algorithm isn't the problem. My problem is that ...
0
votes
0answers
11 views

How to switch between 2 game object while having it move at the same position?

I've been trying to make 2 input which change the state of a game object into another by setting one active and another inactive alternatively. But when you're in one state and you try to input the ...
1
vote
2answers
67 views

How do I make an object destructible?

How do I make one of my objects break into random pieces? I've tried Add-Ons, Blender, and a few other things that I can't remember of the top of my head.
1
vote
0answers
46 views

Zenject injection from an existing in scene prefab

I am trying to use Zenject to automatically inject a reference to a component on a game object that I have in the scene, but can only seem to make the create new component on new object work. Should I ...
0
votes
0answers
87 views

How do I program a fan in a platformer game?

Fan physics I have a platformer game and want to have fans in it that blow in a given direction and if the player presses the jump button they can go even further. How do I do this? side note: I ...
0
votes
1answer
55 views

(Unity) Values set in Start() will be reset?

This is my GameController GameObject in the Inspector (Ignore Suns and Player). Note that ...
0
votes
0answers
30 views

how to move array of GameObject at a time in particular direction in Unity?

I just started learning Unity and c#, my objective is to move array of GameObject at a time in particular direction in Unity
1
vote
2answers
109 views

Do inventory items have to live in the game world?

I'm trying to create an inventory system. There's a few parts to it: Item (scriptable Object just the data like name etc of the item) ItemDatabase which takes array of Item (scriptable object) and ...
0
votes
1answer
25 views

Model turning 2d when it's parented

I'm importing arms from blender for my first person controller but when I make the player the Arms' parent it turns 2d. I have no idea why this is happening so if anyone could help it would be very ...
-1
votes
1answer
113 views

Looping through children in a foreach loop

I have a gameobject with a bunch of empty gameobjects as children that I want to use as spawn positions. I want to loop through each of these positions and have a certain amount of probability that ...
0
votes
1answer
46 views

Resize game object using single drag handle using Unity

Really need your help. I'm trying to create a custom controller for my app to allow users to resize and rotate game objects using a single drag object. I was able to create the code to create the ...
0
votes
0answers
20 views

GameObject transform localPosition not setting when you use a function to set somewhere else in the code

So z position on some gameObject being generated from a prefab was being set wrong. I create to function to do like a reset transform thing, but when I set the localPosition in the function it does ...
0
votes
1answer
40 views

Access a clone of an instantiated object - not all the clones?

I am trying to access the object I instantiate - basically a prefab car instantiates cars (one after one) ..the problem that when try to move one .. they all move together ... what's the best way to ...
0
votes
1answer
71 views

Instantiate unity sometimes lags the game some times it doesnt

I have a script that instantiates a object lets say every half a second. THis object is of the type .fbx and has a file size of 53kb, lets call this object A. When ...
0
votes
1answer
32 views

GameObject.FindWithTag throwing weird errors

I've got 2 first person controller scripts, one that handles functionality for basic movement, the other handling looking around. I also have a "CursorLockManager" script, that handles the cursor ...
0
votes
1answer
154 views

“SetSelectedGameobject” only highlights button on second try (Unity 2017.3)

To support the use of a gamepad in the options menu I set SetSelectedGameObject and firstSelectedGameObject (which doesn't seem ...
1
vote
0answers
106 views

What are the extents of an Axis-Aligned Bounding Box (AABB) in Unity 2D?

In Unity 2D, you can attain values for collider2D.bounds.extents and collider2D.bounds.size. What are the actual "extents" of ...
0
votes
1answer
40 views

How do I move many “static relative to each other” objects around?

I'm currently building an Elevator Bank simulator in Unity3d and I'm stuck on how to reduce the amount of objects it's going to generate when it's done. The simulator will consist of one player (for ...
2
votes
2answers
98 views

I need to keep music playing but still be able to mute it between games, how?

I have a game built in Unity. The game plays music continuously, which can be muted on button press on the scene. This works fine using the below code: ...
0
votes
1answer
22 views

Unable to add button in Unity

I am wanting to add a button to my scene in order to mute/unmute music. I can add the button to my scene, but it's not appearing on the UI. I can't see it anywhere, not on the scene nor the game ...
0
votes
1answer
47 views

How do I prevent repeated interactions between two game objects?

I am making a game where a player will jump into another object called land and everytime the player lands or collides with it, a score will be given, now my problems is that my method has a loophole ...
0
votes
2answers
38 views

How can I access a method on a child elements script in Unity?

I'm using Unity. I have an empty elements called GameElements which I programmatically add child elements to (players can spawn these objects themselves in-game). ...
0
votes
2answers
50 views

After using Unity's Destroy() function, I see the Prefab Clones are now called “New Game Object” is this a problem?

I use a prefab to generate several gameobjects which I then get rid of with the Destroy() function. I noticed the clones, when destroyed are replaced with "New Game Object". Because of the nature of ...
3
votes
1answer
1k views

Unity3d - Do I need to destroy gameobject AND script?

From proper leak protection do I need to delete both of these or will getting rid of one take care of both? Currently I am destroying the script AND the gameobject ...
0
votes
1answer
47 views

Are constantly growing (in dimensional size) GameObjects a problem?

It's possible the following is fundamental to Unity, and not a problem? I am using an example of a WheelJoint2D/Car from the Ray Wenderlich tutorials. Note from the pic below, the top level game ...
0
votes
3answers
49 views

Public value null after assigning it from a different script

Hello I am a beginner in Unity and still currently exploring with scripts. So I ran into a problem. In FetchAndAssign.cs Script ...
2
votes
1answer
61 views

How to create a grid of 3d objects without making them actual GameObjects

Very simple question: If I'm going to be generating and placing a lot of 3d objects (in this case cubes), that are not going to be interactive, like no collision, no raycasting intersections etc. ...
0
votes
1answer
32 views

How to dynamically construct a reference to a game object by name

I have game objects tagged MenuOption0, MenuOption1, MenuOption2, etc. I want to keep a currentIndex var, which gets incremented each time the user swipes on the controller. That swipe should ...
0
votes
1answer
73 views

How to store 3d transformation in a game?

I am curious what is the best strategy to save 3d transformation of a model. Here are the few choices I think about: 4x4 matrix 4x3 matrix(skip the bottom row of a 4*4 matrix) Dual quaternions with ...
1
vote
2answers
75 views

What are common methods for organizing game objects?

I'm in the early stages of developing a game in C++. As of currently, I've defined a base GameObject class that is the base class for any interactive item in my map (e.g. enemies, loot, projectiles, ...
0
votes
1answer
547 views

How to arrange child objects in a grid

i have a gameobject that have a group of plane meshes that created randomly as child every one of this planes have a "2f" offset in x axis between every plane what i wanna do is i wanna make the ...
0
votes
0answers
223 views

How do you rotate a Unity gameobject with the device's gyroscope?

I currently have a gameobject placed atop a wedge as in the image below: I want to make the user have to rotate their device to keep the rectangle balanced upon the wedge. Here is the C# code I have ...
0
votes
1answer
43 views

How can I determine when colliders of two gameobjects touch one another?

I stop gameobjects from colliding with one another by having box colliders around the gameobjects with dimensions bigger than the gameobjects. It works fine, but I want that when the gameobjects ...
0
votes
2answers
33 views

GameObject With Background Covers GameObject Without Background

so I have two sprites, a box and an X animation (I'm making Tic-Tac-Toe). So, in the code, when I click on the box, it instantiates the X animation at the right place. The X animation does not have a ...
0
votes
1answer
51 views

Why is my inherited class's transform always null?

I have a class inherited to another class, and I can't get the transform on the inherited class. Here's what i have and trying to do ...
0
votes
1answer
60 views

How to make sure that a GameObject which gets a certain tag first, is allowed to do something first?

I have created a trigger zone to make sure that only one gameobject should pass through the trigger zone at once. Other gameobjects approaching the trigger zone are made to stop just outside the ...
1
vote
3answers
300 views

Is it possible to have two trigger zones around the same GameObject in unity?

I have created a trigger zone to make sure that only only gameobject passes through it at a time. The moment the gameobject1 entered the trigger zone, it is given a particular tag but I am not how to ...
0
votes
2answers
336 views

When there are multiple objects of the same type, how do I know which one I am colliding with?

I'm working on a platformer game using Gamemaker Studio 2. , and currently I'm dealing with implementing platforms: (Platforms are able to pass through from the bottom, but remains solid when landing ...
1
vote
1answer
75 views

GameMaker Studio 2 - How to place object back beyond X coordinate for looping (warp)?

I'm making a side-scrolling shooter where I want an object to move from right to left (towards negative X), then, when it's passed out on the left side, jump back to beyond the window width (right ...
0
votes
2answers
337 views

How to make UI Button to rotate an gameobject?

I'm trying to make a button to make a gameobject rotate and stay rotating in its own axis (Y) but I cannot make it work... As far as I know it's very simple: Create an empty gameobject (or whatever ...
0
votes
1answer
37 views

How to automatically destroy a gameobject after a method or block of code

In Unity I frequently find myself doing this in C#: ...
0
votes
0answers
31 views

Restore scene by adding stored objects

My game has a bunch of GameObjects that I created with code at runtime and that I "store" in an array in a static class. When I unload the scene and load it again, these objects are gone (of course). ...
0
votes
1answer
908 views

Can a Component.gameObject be null in Unity?

Can a Component.gameObject be null in Unity? If it can what can cause it to be null? The context for the question is a ...
0
votes
1answer
36 views

Unity use image to load prefabs along a line

Say I have an image of PNG or a bitmap with a line zigzagging through it. I have done quite a bit of research in the answer still eludes me to how to use an image in unity and have it generate ...
2
votes
1answer
904 views

Is there a way to make a game object invisible to only certain players?

I have found a few posts and blogs here and there. But all of the solutions they provide seem to be global. Is there a way for let's say a multiplayer scenario where maybe an enemy has a cloaking ...
0
votes
2answers
1k views

Unity, rb.MovePosition and transform.Rotate at the same time

I can't figure out why my object can't move and turn at the same time. ...
0
votes
1answer
632 views

UnityException: Transform child out of bounds (only in built APK)

In the Unity Editor, this code helps me to get the Fog GameObject: ...