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

How to make sure two Tiles not overlap each other?

I'm trying to make a Grid who will be easily convertible between 2D and 3D and I'm having a problem with overlapping prefabs in the case of the 3D generation. The thing is, the DataObjects (Tiles) ...
2
votes
2answers
88 views

Programming Pattern: Representation of pick up objects

I'm pondering about the best way to represent objects that can be picked up in my 2D engine. I have an Actor class which is the base for all objects that can be spawned into the game. This class ...
3
votes
1answer
1k views

How can i detect if the player is inside an explosion radius?

I'm making a driving game, there are enemies which spawn on the side of road and when my player car gets close, they fire a rocket in front of the player. I need to detect if the car is within a ...
0
votes
1answer
301 views

How to put a reference to my player (already instanced) into a prefab that will be instantiated later [duplicate]

I'm making an enemy in my game. He stands at the side of road with a rocket launcher and fires when you get close. It nearly all works fine, except I just need a reference to the players position so ...
0
votes
1answer
112 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 ...
0
votes
1answer
65 views

I have problem understand instantiating new objects in Unity at runtime , help please :)

Hi again you fine folks. So I'm making a driving game and there is going to be some cows in the road you have to dodge. Currently I've laid 3 spawnpoints in the form of flat cubes, with the ...
1
vote
0answers
66 views

Unity - Touch Input help needed

I'm just starting to learn Unity and I must admit at the moment im struggling linking my code scripts together. Im used to having a main class to work from. I have been trying to implement virtual ...
0
votes
1answer
521 views

How to store an array of prefabs together with configuration parameters

I have attached the following script to a number of weapon prefabs: ...
2
votes
1answer
13k views

How to instantiate an array of Prefabs in C# Script

Sorry if this sounds quite primitive, I am new to Unity. I am trying to instantiate an array of prefabs, but it doesn't seem to appear when I run the game. Firstly I created my block prefabs, then I ...
1
vote
0answers
314 views

How to stop rendering a gameObject that has no rendering component in unity

I want to stop rendering this gameObject. But the all-available renderer.enabled = false is not working. Is it because it has no rendering component attached? If so, how can I see it when it is not ...
0
votes
1answer
150 views

A logic error. canvas: balls physics, bounce

Hi I was making a program that simulate a bunch of balls bouncing, but the problem is some balls got stuck to the floor. Since it's a logic error, it is kind of difficult to find. Can someone help, I ...
0
votes
1answer
51 views

Tree of objects in 2D space - children relative to parent

Question How do we track the position of child objects, relative to a parent? Context I have a simple structure that keeps track of a point in space, along with zero or more children: ...
-1
votes
1answer
902 views

Why is my Unity scene prefab auto-changing?

I have some prefabs which are instantiated in game. There are some attributes of prefabs such as size(width, height), text string and color which are changed from code. Well, it is working fine. ...
0
votes
1answer
167 views

How do I enable a Box Collider when a timer reaches 0?

I'm pretty new to Unity, and I am trying to enable a BoxCollider from another object when the timer reaches 0, using this code: ...
0
votes
1answer
82 views

Identify objects of the same type from each other, even between game restarts?

So I have a simple Character class: ...
0
votes
1answer
370 views

How do I delete the parent game objects attached to a script?

How do I delete the parent game objects attached to a script? You can see my code as an example, which is only removing the script on a game object. I am using Unity 5.5.2f1. ...
-1
votes
1answer
138 views

In UnityScripting C#, What's the distinction between global coordinates and world space?

In Unity game engine and C# scripting; Is there any distinction between global space and world space? Are this two the same thing and identical or there is a distinction? I'm not confusing between ...
1
vote
2answers
505 views

Unity 5 - Place objects in game to closest gameobject

I am making a puzzle game in unity3D 5 for school and one of the puzzles is this: The player (third person) can pick up certain objects (4 objects) and has to place them inside holes in a wall in a ...
3
votes
1answer
2k views

How can I have realistically bending/flexing paper?

I am a new hobbyist to Unity and I working on a game where the player goes around picking up clues in the form of paper notes to solve a mystery. So far, thanks to the help I got here, I was able to ...
1
vote
0answers
74 views

Designing Game Items in Mystery Game

I am currently working on a Mystery Game, where the player has to evolve in a small hamlet and find clues to solve a mystery. The game is a first person view and the feel is going to be somewhere ...
0
votes
1answer
48 views

How to reference a GameObject that shares position with gameObject in Unity C#

Well, thats a weird title. What i am trying to do is identify the object which position matches the gameObjects position that the script is attached to. Hell, that didn't make it better. Here's my ...
-1
votes
1answer
55 views

Adding components to the correct game object

I created a MonoBehaviour with a LineReader, to draw multiple lines. I'm attaching radius indicators for when I debug enemies in ...
0
votes
1answer
422 views

Re scaling an object from its current scale to a scale of 0

I want to have an animation which starts at a starting scale of whatever the current gameObject's scale (i.e 1, 1, 1 or 2, 3, 2) is which then end at a scale of 0, 0, 0. The problem is that Unity's ...
0
votes
1answer
756 views

Unity 5 Animator will not disable

I am making a small FPS in unity 5. I made a cursor animation that I want to play only for a brief moment. I tried to do this using some code: ...
-1
votes
1answer
121 views

Raycast2D ray not follow object

I have some Raycast2D problem. I want raycast follow the object like this: But when I drag object somewhere the ray looklike this : Here is my code where is my fault. Please help :( ...
1
vote
2answers
716 views

Unity: How to keep the music muted on reloading the scene?

I am giving the user a UI button to mute and unmute the ingame sounds but the problem is when I mute the sounds and then when the game ends and the game scene reloads the sounds comes back up which is ...
1
vote
1answer
6k views

How deep does the GameObject.GetComponentsInChildren() , Go?

So I have a GameObject which my scene will be it's children. I wanted to get the BoxCollider of all the objects and their sub-...
4
votes
1answer
479 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 ...
7
votes
5answers
25k 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 ...
0
votes
2answers
7k views

How to make Lists (and Arrays) in Unity only take GameObjects of a certain “type”

If I were coding in generic C# I can create a list that only stores a certain type of object. If I accidentally try to add anything other than that type to the list I will be promptly told and can fix ...
-2
votes
1answer
39 views

Changing an objects on through C# script in Unity

I am trying to export my Unity project to Android Studio so that I can create some Android buttons that "controls" the Unity app's behavior. I know what I have to do in order to let it access through ...
1
vote
0answers
81 views

Make a decal a physical object?

Is there a way in the UE4 to make a decal such as a blood decal and give it a physical object? I want to do it so that I can add a sound affect when the player walks on the physical object, a box ...
1
vote
1answer
1k views

On Click Add Listener not working on Game Object

I have this code attached to a 3D cylinder game object. I plan to use it as an arrow and rotate it when clicked and dragged. I had no idea what do as I am a beginner so I started with adding an ...
1
vote
0answers
64 views

Finding the Dimension of OBJ objects

I am having a Three OBJ file , Cone , Sphere and Cube. How can i find the dimension of these objects , so that i can use it in ...
0
votes
1answer
280 views

What happens with associated animation clips when I copy a gameobject in Unity?

I have a gameObjectOne that has two animation clips: move into the screen and move out of the screen. This gameObjectOne has an animator that checks when each clip has to be played. Now I duplicated ...
0
votes
0answers
56 views

Which GameObject should I put the animator on?

I have a GameObject. One of its children is an empty GameObject, whose children are the body parts which need to be animated. ...
0
votes
2answers
773 views

How do I pause and unpause gameobjects on is own in the scene without pressing keys in unity3d

I can't get my gameobject to pause or unpause in the scene in Unity3d. I need the game to pause for a couple of seconds maybe longer than unpause by itself. Here is my script : ...
2
votes
2answers
2k views

How to automatically delete an object in Unity?

I am new to unity and the other day I was wondering that it would be useful if I could instantiate some objects in my game scene and, as they get instantiated, make it so that they get automatically ...
1
vote
1answer
59 views

What is this tracking circle called as?

I don't know what the circle in the image below used for changing directions and movements of a character is called. Can anyone provide me anything related to it? I want to include it in my game.
-1
votes
1answer
352 views

How do I use Couroutines for spawning and spawn certain amount of enemy AI in the scene?

I have made a spawn function for spawning enemy AIs, and it didn't work well in my scene. I have the enemy AIs spawning in the update function, and it initially works fine, but it's spawning too many ...
-2
votes
1answer
86 views

gameObject and col.gameObject both get destroyed

I want a square[0] to be destroyed by triangles(tag = 2) and circles(tag = 3) when the square comes into contact with them. Also I want square[0] to destroy square(tag = 1) and not be destroyed ...
0
votes
1answer
343 views

Unity2D - How to destroy my Instantiate particle system

I'm having trouble trying to destroy my Instantiated particle system, I can only destroy my gameobject ...
3
votes
0answers
107 views

How to disable and enable a randomly generated prefab in an endless runner 3d

Hi all I have been experimenting the endless runner game for some time and needed to optimize it. I read some articles about optimizing my game and it says that once you instantiate the prefabs in the ...
0
votes
2answers
1k views

Prefab Instantiates into scene, but when I store a reference to the instance it's null

I am instantiating and parenting two objects - the first is a Unity primitive and the second is a prefab cube (literally nothing but a cube made into a prefab). The direct instantiation of the ...
2
votes
1answer
5k views

In GameMaker how to check if instance is a given object?

Let's say, I have three objects: obj_square, obj_circle and obj_triangle. Instances of all ...
1
vote
4answers
1k 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 ...
0
votes
2answers
6k 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 ...
1
vote
1answer
8k 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 ...
6
votes
3answers
1k 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 ...
0
votes
1answer
258 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 ...