Questions tagged [gameobject]

GameObject is a key component of the Unity3D engine. It is often associated with Unity3D questions.

GameObject is a key component of the Unity3D engine. It is often used in the engine when developing games and apps. It can be added to a Unity scene to represent and control many game elements such as UI, audio, effects, lighting and various objects. The GameObject can have multiple components added to it, including a script to control its behavior and attributes.

708 questions
-1
votes
1 answer

Unity hit.rigidbody reference to concrete gameObject

I've got Menu with 3d texts. Main Camera has got animations that I want to play after clicking on text. Every text has its own rigidbody and collider. I made this code: #pragma strict import UnityEngine; var object : GameObject; var Run :…
janw23
  • 65
  • 6
-1
votes
3 answers

Transform rotation to movement direction in 2D space

I am trying to rotate my GameObject to be facing in the direction that it is moving. I am not using Rigidbody.Velocity, I am just using transform.position to move the object. Here is my code: public GameObject player; void Update () { Vector3…
Barney Chambers
  • 2,720
  • 6
  • 42
  • 78
-1
votes
1 answer

I get an error sometimes when i shoot

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. …
-2
votes
0 answers

Gameobject is getting black after rescale it by code

If I change the size of my game object it gets black. Please help I allready tried to set a white matherial, but after the first rescale its getting black. To rescale it I used the localscale Method and if i rescale it in the editor it workes. Just…
-2
votes
1 answer

Operator '-' cannot be applied to operands of type 'Quaternion' and 'Quaternion'

I was trying to merge two rotation value with the datatype Quaternion in unity C# script but this error came up. I tried to search for answers but there was either unsolved question or the ones that have been answered is not working. public…
P D
  • 23
  • 8
-2
votes
1 answer

How to reference a script from another script to access multiple variables in unity c#

Hello I have 2 script my recoil script and my gunystem script I have my recoil script on my camera recoil obj as a child of camera rot obj I have my gunsystem script on multiple guns i am trying to make all guns have different recoil how do i do…
-2
votes
1 answer

Instantiated Object sometimes gives NullReference but sometimes not

So i am trying to make a simple gameobject saving system in Unity. Whenever i place an cube i enter it in a GameObject called currentCube GameObject currentCube = new GameObject(); currentCube = Instantiate(CubeBlue, placeLocation, new…
-2
votes
2 answers

Unity C# error: (12,47): error CS1503: Argument 2: cannot convert from 'System.Collections.Generic.List' to 'float'

I'm new to programming in general. With another Script i store in the list "spawnPointC" all gameobjects called spawnPointC that appear from spawning other prefabs. I want to pick a random GameObject from that list, and store it's position to spawn…
-2
votes
1 answer

Unity GameObject not found

Hey guys this is my first time try to make simple game in Unity but i got stuck in movement script, I already have script for my player called "player" script, so now i'm trying to make a script for my controller which is a touchscreen pad, like…
-2
votes
1 answer

unity/c#: data from another gameobject

I want in my Unity game, to get a float of another GameObject. The Gameonject is called "Spawner", the script on the GameObject "CarZSpawner" and the float in the script "mult". The float "mult ist changing every few seconds." i tried many things…
Jan
  • 19
  • 3
-2
votes
1 answer

How do i pull the Collider Data out of this sorted array bassed on the object tag and Assign that object to the Target in C#

GameObject GetTarget() { GameObject TopTarget=null; Collider[] col = Physics.OverlapSphere(transform.position, checkRadius, checkLayers); Array.Sort(col, new DistanceComparer(transform)); foreach (Collider…
-2
votes
1 answer

set GameObject to Script's public variable pragmatically?

I'm trying to make decision in my script if I get a value 1 then run specific game object which is (PopulationGenerator of population engine asset). I have 3 population generator in my scene but I can't assign any of them pragmatically in the code…
Mahmoud Elgindy
  • 114
  • 1
  • 11
-2
votes
1 answer

GameObject[] is less accessible than (prefabs)

This basically sets up the tiles for my endless runner, the error in particular being: Inconsistent accessibility: field type 'gameobject' is less accessible than tilePrefabs using System.Collections; using System.Collections.Generic; using…
sunsetfox
  • 1
  • 2
-2
votes
1 answer

How to apply trasform rotation at global space in Unity5?

When you use Blender to apply rotation as well as Unity3d: If you do it using the transform properties doesn't matter if you are on Global space or Local space, you get the same result. But in Blender you're allowed to apply rotations specifying…
Karmavil
  • 863
  • 10
  • 13
-2
votes
1 answer

C# - SetActive dont work?

can someone tells me why my gameObject doesn't activate again? Thanks. C# Code using UnityEngine; using System.Collections; public class SlowerPowerUP : MonoBehaviour { // Use this for initialization void Start () { } // Update is…
xXElsterXx
  • 39
  • 1
  • 1
  • 10
1 2 3
47
48