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
0
votes
0answers
15 views

C++ OpenGL: Object Components

I've been trying to make a barebones engine/game in VS C++ with OpenGL. So far it's worked well, I've managed to render two green triangles on the screen and can accelerate one using WASD input. ...
0
votes
0answers
20 views

Does anyone know what caused this? [duplicate]

My code was working until the program crashed, then it started showing this. I actually don't know what caused this, but it was working before the crash... I have recently started programming so I don'...
0
votes
1answer
24 views

Unity: Unsharp edges

I have a Unity Project and somehow the edges of objects in my Scene (Scene view and game view) look like this: I think I already had that problem once, but in my recent projects, this didnt happen ...
0
votes
1answer
42 views

Instantiation of a custom class

I have a custom class named Stars: ...
0
votes
2answers
40 views

How to store a Transform[,] grid in an ArrayList?

I am new to Unity game dev and trying to expand my knowledge of data structs. I'm building a match-3 game, and I currently have a multi-dimensional ArrayList holding transform coordinates on a grid of ...
0
votes
2answers
47 views

Updating object's property on Start is visible for a second when game loads

I have a world selection scene in which I have GameObjects representing worlds. The GameObjects have default properties when the ...
-1
votes
1answer
33 views

Null reference on gameObject that has been successfully referenced [duplicate]

It's exactly as the title says. I am getting a null reference error even though I have properly referenced the object. I have debugged my code to show that the result is always exactly what I need ...
1
vote
1answer
38 views

How can I insert a prefab instance programmatically inside the Canvas, in the bottom-left corner of the Canvas?

I am trying to create the Snake game in Unity, based on this video tutorial. I have also viewed this tutorial. I have created the new project with the 3D template and manually added the Canvas. I ...
0
votes
0answers
13 views

Place a GameObject Parallel to a Point on a Sphere [duplicate]

I'm trying to place an object parallel to a sphere in Unity3D. With the following code from here: ...
0
votes
2answers
90 views

Querying game objects in real-time

I'm thinking about working on a game where I need to find all the objects matching certain properties. For instances I might need to look up all the objects... Producing gold. Whose level is 5 or ...
-1
votes
1answer
61 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 ...
0
votes
1answer
62 views

Creating a prefab throws issue

For past couple of hours I'm trying to create a new prefab out of my environment but it keeps throwing an error: Error: You are trying to replace or create a Prefab from the instance '...
0
votes
1answer
89 views

Dealing damage over multiple frames without damaging the same enemy twice

I am using Physics.Overlap to find which enemies are in my damage range. But dealing damage in only one frame is not what I want. Some attacks should be active for ...
0
votes
1answer
43 views

Spawn Array of GameObjects to Array of Transforms

I have a question regarding spawning an array of GameObjects in Unity. What I want to happen is that when a big enemy dies, it will spawn enemies into their respective Transform positions (i.e., Enemy ...
0
votes
2answers
97 views

Why is there a gameObject inside a GameObject

In order to manipulate a game object via script in Unity I need to access the gameObject inside the main GameObject. Why is it ...
1
vote
1answer
67 views

How to Make Different Instances of an Object Have Different Sprites

In Game Maker, I am trying to make it so that three instances of an object have three different sprites. Using DnD, what would be the optimal way to do this? If it helps, the three instances are ...
1
vote
1answer
48 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 ...
0
votes
1answer
41 views

How do I make a GameObject carry across only 2 specific scenes?

I have a GameObject in my main menu and help scenes that I want to carry across both scenes but be destroyed on all other scenes. I am having multiple issues with it such as it wont destroy on other ...
0
votes
2answers
57 views

In Unreal Engine 4, how do I get the component's “game object” via C++?

I have an ACharacter instance with a weapons component that inherits from UActorComponentattached to it. I'm currently writing ...
0
votes
1answer
52 views

Unity3D: Move the parent gameobject relative to the child

So, I have X and Y game objects. I have a vector Z = X - Y which is indicated by the green line. Also, I have a ...
0
votes
2answers
82 views

How to make extendable Mario warp pipe in Unity?

I want to make a warp pipe from the Mario games in Unity. The key feature of this object will be that I can set the length (height) of its "neck" to any length I require, as long as it is greater than ...
0
votes
2answers
87 views

My GameObject keeps spawning when it shouldn't

I'm trying to instantiate a new gameObject when the current gameObject gets to a select point. The problem comes when the program gets to the second if() statement. It sets the floorsSpawned to 1 and ...
0
votes
2answers
83 views

How to reference a GameObject from the Scene Hierarchy in C#?

I am a novice in Unity. I have a Game Object named 'courtsuit'; you can see it in my Scene Hierarchy panel here: I added that object instance to my scene by dragging an OBJ file from my Project ...
0
votes
1answer
51 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
111 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
134 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
75 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
213 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
101 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
224 views

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

This is my GameController GameObject in the Inspector (Ignore Suns and Player). Note that ...
1
vote
2answers
144 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
33 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
1k 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
195 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 ...
1
vote
2answers
187 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
252 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
51 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
754 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
162 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
46 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
169 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
23 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
53 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
145 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
169 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
2k 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
51 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
53 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
115 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. ...

1
2 3 4 5