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
1
vote
1answer
1k views

Using StartCoroutine() and WaitForSeconds()

I am trying to perform two operations. First I want to increase the size of a GameObject and then delay for 0.1s before returning it back to its original size. However, when I try using StartCoroutine(...
0
votes
1answer
27 views

Attach the UIButton to Component Via Script (C# Unity)

I want to attach the UI to the MC_Streaming Option Script via Code . What i wanted here is that this live_onOff will go to the Livestream(MC_Streaming Option) ...
0
votes
1answer
135 views

Calling Functions from Other Scripts

Say I have three different gameObjevcts, each representing rock, paper or scissors. These objects all have a Player script ...
0
votes
1answer
220 views

Destroyed GameObject but still trying to access it(C# Unity)

EntryPoint.cs ...
1
vote
1answer
35 views

How does Actionscript choose which order to run objects' code in?

I can only assume that Flash runs code in the order that objects were created - so newer objects are run later. Is this true? Is there any way, other than deleting and recreating objects, that I can ...
0
votes
2answers
323 views

Is it more efficient to add scripts to each GameObject or to a single parent object?

Does a C# script added to a parent object work more efficiently and effectively (in terms of both memory and performance) on all objects, in my case lighting, or adding script components to each ...
0
votes
1answer
1k views

Trying to get an object to move in the mouse direction XNA C#

Right, so in my Player class where I call the object I got an if statement which gets the coordinates for the mouse ...
0
votes
1answer
647 views

Difference between Object.Destroy() and GameObject.Destroy() in Unity

What is the difference between using Object.Destroy() and GameObject.Destroy() in Unity? I found the following info about that: ...
2
votes
1answer
432 views

How to make a boss control multiple object spawners in Game Maker Studio 2

I'm working on a boss fight for a 2D platformer/shooter game in the vein of the Megaman franchise. I expect part of the fight to include this boss causing large boulders to fall from certain points on ...
0
votes
2answers
123 views

Synchronizing "token" between players(multiplayer) [duplicate]

I am implementing the multiplayer(client-server architecture) of a game, and I came to doubt about entities common to players. I understand how to share information such as the position of the ...
4
votes
1answer
13k views

ScriptableObject referencing a gameobject in scene

What I'm using for the scriptableobjects that requires a reference of a gameobject in scene is for scheduling events like for moving. Meaning a scriptableobjects should have a gameobject or waypoint ...
0
votes
1answer
839 views

Unity, Detect the last GameObject in the hierarchy of a given list of GameObjects

I have a list of GameObject , and I need to know which one is the last in the hierarchy ( This is for a UI system, So is kind of 'which one is showing up') I have a cursor managed by GamePad , and I ...
0
votes
0answers
117 views

Best strategy to track object hierarchy using groups and obj files

I am making a 3D game in OpenGL from scratch. In this game I have a ship with stuff inside it. How can I attach the stuff to the ship in the CAD program and maintain that hierarchy in my own game? ...
2
votes
2answers
66 views

Appropriate use for prefabs in Unity in a coordinate based game?

I am wondering how exactly to use prefabs in Unity for my discretely coordinate-based game. Should they only be for gameObjects that are exactly the same? Or can they have small variations? Example: ...
1
vote
0answers
360 views

Resize from one side of the object in runtime Unity

For now I managed to resize my object but it resizes always from the center. I have the same problem like this question here. I've been thinking like adjusting the position and stuff, but nothing ...
9
votes
3answers
847 views

How to have multiple GameObjects sharing pieces of same material?

My question is: There's any way of having GameObjects sharing pieces of same Material, not a clone, but an extension of one? For example, in these case nine game objects sharing just the same material ...
2
votes
0answers
319 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
98 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
372 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
119 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
72 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
576 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
16k 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
368 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
153 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
52 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
1k 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
209 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
407 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
141 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
575 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
3k 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
75 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
64 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
58 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
517 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
795 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
123 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
780 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
7k 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
513 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 ...
8
votes
5answers
33k 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
8k 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
40 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
65 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 ...