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
0 answers
14 views

When I run the game, the gameobject is not disabled? [Unity] [closed]

I have an empty gameobject with animation on the scene. I deactivate this object and it automatically activates when I run the game. I want the object to be active only when certain conditions are met....
user avatar
  • 13
1 vote
0 answers
97 views

No Collision while rotating. Object rotating with Rigidbody.Rotate passes through other collider

I'm working on a 3D game, and having issues with the colliders. My Cube Controller has movement input by keyboard, with collider and rigidbody components. Cylinder objects have basic colliders and ...
user avatar
  • 11
0 votes
2 answers
57 views

How to find out the type of GameObject selected in the scene?

If I select some GameObject in the Unity, e.g. recently added TextMeshProUGUI inside the ...
user avatar
  • 121
2 votes
0 answers
77 views

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

There is this property defined in the GameObject class: ...
user avatar
  • 121
0 votes
0 answers
59 views

GameObject.Instantiate isn't applying rotation

My scene has a GameObject positioned out of camera view. Let's call it 'Cat' Cat's transform.rotation is (0,90,0) I have a script bound to an otherwise-empty GameObject. Let's call it "...
user avatar
  • 139
0 votes
0 answers
33 views

transform.localPosition does not wok in Unity

When im breaking fence GameObject there should pop up scores, so it works fine. But position of pop up scores is too low, im trying to raise it by ...
user avatar
  • 1
0 votes
0 answers
15 views

How to make golf putter rotate to ground normal's and still rotate with the handle

I am making a vr golf game and I am trying to get the putter to be level with the ground and still rotate with the putter handle. The two pictures below will demonstrate the problem. Then after I ...
user avatar
0 votes
0 answers
80 views

How do I write a script for Unity that allows a gameobject to be scaled using pinch & zoom touch controls?

I need a script for Unity that allows a gameobject to be scaled using pinch & zoom touch controls. I have found lots of answers for scripts that cause the camera to zoom in/out but I want a ...
user avatar
  • 1
0 votes
2 answers
366 views

How to Spawn GameObjects at Random Positions in Unity? [closed]

Hello GameDev Community, I have a problem with this pice of code. If I start the "Game", it crashes right away. Probably is its the list of GameObjects or the foreach loop. I have no idea ...
user avatar
  • 3
-1 votes
2 answers
115 views

Parent object does not rotate on its own axis with its children. How do I fix it?

My parent object components: Rigidbody2D and the script I shared below. Children(Head, Body, Arm, Backpack...): There is only collider. There is no rigidbody2D. (I want the parent object to use the ...
user avatar
  • 13
0 votes
0 answers
51 views

How can I organize in Unity's hierarchy GameObjects that are spawned in a nested structure?

I'm wondering how I can organize instantiated GameObjects that are spawned in sort of a nested structure. I'm spawning these GameObjects via Containers, a set of ...
user avatar
0 votes
1 answer
78 views

Combining two objects to give you one more elaborate one

I'm looking for some help to someone throw me a light on this problem I'm having. We're making a clothing game where you got to grab a "cloth" and a "string" and bringing them to ...
user avatar
  • 1
1 vote
1 answer
69 views

How do I create an event trigger system for a Discord bot?

I am making a card game and I am having issues implementing "effects" and effects that are continuous. How can I get effects to activate at the right times, before and after an attack does ...
user avatar
0 votes
1 answer
83 views

disabling or enabling a public component

I need to be able to disable only a specific component of an object publicly. I got a public component but I cant find any ways on the internet on how to disable and enable that component. Here's the ...
user avatar
  • 85
0 votes
1 answer
46 views

Should map labels be gameobjects or on a canvas?

I want to label the countries in my game, like in the picture below. Should the country names be normal unity game objects, or should they live as a textmeshpro on a canvas? For what it's worth, I ...
user avatar
-1 votes
1 answer
53 views

how do i destroy a DontDestroyOnLoad Gameobject

I have a DontDestroyOnLoad Gameobject and i just can't destroy it I have tried a lot of things. ...
user avatar
2 votes
1 answer
115 views

How to manage a lot of items on conveyors

I am making some sort of factory game (topdown 2D) where I will have machines outputting items on conveyors. I was wondering what was the best approach to manage the items on the conveyors. There are ...
user avatar
0 votes
0 answers
14 views

How do i Change a GameObject from another script to the GameObject the current script is on [duplicate]

im trying to set the game object in script1 to be the game object script2 is on ...
user avatar
0 votes
0 answers
29 views

Why aren't my Vector3 comparing correctly?

I have a machine and a I want to check if I can place a conveyor at its connexion point. I do it by checking if the machine is at the expected Input position of the conveyor and if the conveyor is at ...
user avatar
7 votes
2 answers
1k views

How "smart objects" are implemented and actually work?

I'm drafting my game and implementing small stuff in it, but hit a roadblock. You see, for my game I would like for different items to behave the same or to share behavior, for instance, some items ...
user avatar
  • 203
0 votes
0 answers
27 views

Organising gameobjects into multiple lists

I have a very simple little game that consists of a player, zombies, food, and treasure. It's all automated. The player will walk towards a zombie and shoot within a certain distance, which costs ...
user avatar
0 votes
1 answer
71 views

How to deal with data that needs to be accessed by all objects?

I have a World class that currently only has one instance. It has data and methods that need to be accessed by all other game objects. Right now I'm hardcoding a ...
user avatar
1 vote
2 answers
570 views

Button onClick in a menu prefab doesn't work

I don't seem to be able to make a reference to a Button inside a menu prefab. My menu prefab consists of a panel and the panel has 4 buttons. I added ...
user avatar
2 votes
2 answers
246 views

How to organize GameObjects into logical groups in a Unity Scene?

Obviously there are a Scene hierarchy, but the problem is that the scene hierarchy was not meant for organizing GameObjects because parent GameObjects affect the transformation of their children. For ...
user avatar
3 votes
2 answers
129 views

Change Text - Inside A button, inside a Canvas, inside a GameObject: Access all the texts inside of hierchy?

//.... Gameobject tile; int count = 1f; float posX = 0; float posY = 0; ....// GameObject blueTile = (GameObject)Instantiate(Resources.Load("block_blue")); tile = (GameObject)Instantiate(blueTile, ...
user avatar
  • 131
0 votes
1 answer
40 views

can't instantiate different objects

I'm trying to instantiate different prefabs at once. But couldn't figure out how. I tried to use Random.Range method but didn't worked for me. It instantiates only one of the prefabs. I want it to ...
user avatar
1 vote
1 answer
146 views

Instantiating GameObjects in Custom Game Engine

So,i'm having a bit of an issue with instantiating my gameobjects into to universe(My Scene object). I can create an empty object from scratch and populate it from there with ease,my problem starts ...
user avatar
  • 48
0 votes
1 answer
496 views

How would I go about adding a tooltip to a Unity UI Image?

I'm going to try out the community here once more, I haven't had very good look in the past with getting help. I'm iterating through a series of List() and I'm creating a bar graph and a line graph ...
user avatar
0 votes
0 answers
42 views

Unable to wire UI Text object to C# Script

I have created UI text object And then created Text field in behavior class: ...
user avatar
  • 151
0 votes
0 answers
117 views

Why my capsule collider sometimes stucks in other colliders?

I'm creating a third person game, and sometimes I face a strange bug that I cannot figure out. Indeed the player may remain stuck in static scene objects, and cannot escape until an angle large enough ...
user avatar
0 votes
0 answers
28 views

Get and destroy gameobject component of same type

I want to destroy any graphic component on a gameobject , example is image,raw image, sprite , ect .But i don't have the list of all graphic component so i don't know how to loop through it . The ...
user avatar
0 votes
0 answers
43 views

What would be the best way to find a Game Object that is closest to another Game Object in unity?

I made a 2d space shooter game awhile ago and I want to go back into it and overhaul some things. I'll provide a link to the game so anyone can play and get a better understanding of what I'm trying ...
user avatar
0 votes
0 answers
81 views

Is there a way to get the actual joystick.Vertical and joystick.Horizontal Value?

What I want to do is Pass a parameter called joystick_tag. (like this: Get3DJoystickPosition(joystick_tag)) Get the current ...
user avatar
  • 1
3 votes
2 answers
113 views

How to Iterate thru game object and access scripts by name?

I'm using a "toggle visibility" script on many objects in my scene, and in my gameController class I'm storing references to them in an array like this: <...
user avatar
  • 33
0 votes
1 answer
283 views

Detect a collision between a CharacterController and a 3D Object?

I am making an XR game, and I am stuck with a part. Does anyone know a function that would detect this? OnCollisionEnter and ...
user avatar
1 vote
1 answer
130 views

Management of objects as targets of other objects

I have started my first game three years ago and learned a lot during that process. Now I would like to rewrite it to incorporate my "lessons learned" or try out new ideas. My game consists of space ...
user avatar
  • 133
0 votes
1 answer
26 views

List to hold copies of a prefab for later deletion

I'm working on a game in which obstacles are Instantiated randomly 5 to 20 units ahead of the player. When they are instantiated, I want to add them to a list so that when there are too many ...
user avatar
0 votes
1 answer
81 views

Reduce emission of sphere object with HDRP material

I have a material which I have assigned to be used on a sphere game object which acts as stars. This is what the settings are set to: And this is what the Game View looks like: I have also tried ...
user avatar
  • 141
1 vote
1 answer
62 views

How to set the color of a game object as of the other?

I am 15 year old Indian student and I am creating my first 2D game in Unity. I have set the color of my player as Random and I have to set the color of my game object as of my player. But the color of ...
user avatar
0 votes
1 answer
98 views

How to differentiate between object types and roles?

I have a base class Object, and depending on how the object must behave on the scene, I have multiple abstract "role" classes, that inherits virtually from ...
user avatar
  • 153
0 votes
0 answers
42 views

Generating objects in Open Worlds

using Unity I have an open world (infinite) which is proceduraly generated in chunks. In this world I want to proceduraly load objects/trees/grass by raycasting them around the player position and ...
user avatar
  • 1
0 votes
1 answer
967 views

In Unity, how do I add a MeshFilter to an empty GameObject to generate a procedural model?

My code below is modeled after Unity's documentation. When I put the script into an empty GameObject, the error I get is: MissingComponentException: There is no 'MeshFilter' attached to the "myMesh" ...
user avatar
0 votes
0 answers
158 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. ...
user avatar
  • 1
0 votes
1 answer
71 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 ...
user avatar
  • 101
0 votes
1 answer
99 views

Instantiation of a custom class

I have a custom class named Stars: ...
user avatar
  • 141
-2 votes
2 answers
211 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 ...
user avatar
0 votes
2 answers
50 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 ...
user avatar
  • 111
-1 votes
1 answer
170 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 ...
user avatar
  • 27
1 vote
1 answer
316 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 ...
user avatar
0 votes
2 answers
188 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 ...
user avatar
  • 443

1
2 3 4 5 6