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.
0
votes
1answer
46 views
Unity why do all gameobjects not dissapear from view when I switch cameras?
I am having trouble with camera switching. I have two cameras: "Camera1" and "Camera2". A "button script" attached to Camera1 allows a switch to Camera2. It also positions the cameras.
There is a ...
0
votes
1answer
33 views
Determine facing direction mecanim 2d movement
I'm using this script to move my character in my 2d world:
public float speed; //Movementspeed
public Rigidbody2D rbody;
Animator anim;
void Start () {
rbody = ...
2
votes
1answer
81 views
How to remove a component of an object in a script?
I want to remove a Sphere Mesh Renderer component from a certain gameobject. I want to do this in a script. How do I do it? I do not want to destroy the sphere itself, just the component
0
votes
1answer
18 views
How to check if an GameObject exists in Unity2D? (Javascript)
Im making an AI that checks if the player exists or not. How do I check if a certain object exists and put it in a boolean variable?
0
votes
1answer
43 views
Where should I save game object's attributes (hp, score) in Swift?
Scenario: I have a game with several game objects on screen. Each can have different score and hitpoints. When I use collision detection for cannonball vs. ship (example) I need to know which ship is ...
0
votes
0answers
21 views
How to use objects with different attribute values in Swift?
I think this is a really basic question and to make it easier to understand what I do not understand, I use the following scenario.
Scenario: I have two or more ships in my game. They should have ...
2
votes
1answer
57 views
Diversified Game Object List
Recently I started creating a game in java to hone my rusty java (I work primarily with cpp) and because I thought it to be a neat idea. To better illustrate the problem, let me explain a part of the ...
0
votes
0answers
85 views
Unity3D - Unable to attach script to GameObject prefab at runtime
I've got a script that manages a scene browser within my application where I'm hoping to generate a new button instance for each scene found. I've put together a button that I've made into a prefab ...
-1
votes
2answers
74 views
How to enable and disable scripts on a Game Object?
This worked briefly yesterday, I believe I did something to mess this up. All my inputs that I put in are correct; therefor, it must be the code. I want to switch players. While the red cube's script ...
0
votes
3answers
103 views
Unity 2D - Instantiate a GameObject and scale it every second
I want to make a bomb-like game object, that when instantiated, takes 2 seconds to charge, and then some other event triggers. The problem is I can't make it scale smoothly for 2 seconds, and then ...
1
vote
2answers
291 views
What's the difference between Destroy() and SetActive(false)?
I read about both methods in Unity and wanted to ask about which was the best in efficiency : destroying the object or deactivating it. What is the performance difference?
0
votes
2answers
46 views
Can we create same name class for different objects in unity?
I have four similar objects in my game. As they are all similar therefore I have created a single script that defines mash for all of them. The script that defines mash for these objects uses a ...
4
votes
4answers
233 views
What are the differences between using “GetComponent<Transform>()” and this.transform?
I've been reading some example codes and working on my own stuff in Unity. I've been seeing a lot of GetComponent, and often this will be done for the transform:
Transform _transform = ...
2
votes
2answers
210 views
How to apply a script to multiple Objects in Unity?
In Unity, I've almost 200 or more objects. I wish to apply single script to all those objects.
I'm a beginner & learning scripts in Unity.
Edit: At the time of editing the scene itself.
1
vote
1answer
59 views
Unity3D - GameObject as a static function
Newbie Unity3D/C# developer here.
I've tried learning Unity3D during my May/June college vacation and came across a problem:Code 1:
CameraObj returnVoid;
void Start ()
{
returnVoid = ...
0
votes
1answer
53 views
LibGDX destroy object when not used
I am developing a game where objects move in the screen. My object is instantiated in Y = 0 and I want to destroy this object when it goes under the screen Height.
So if (positionY >= ScreenHeight) I ...
0
votes
1answer
43 views
Design Pattern for “Default Object”
I'm making a first person dungeon crawler like Eye of the Beholder.
During execution, I have a Map object. It contains Cell objects. Anc each Cell contains, at most, four Wall objects.
The Wall ...
1
vote
2answers
88 views
Accessing a newly Instantiated Object
I currently am creating a script that allows the player character to attack by shooting orbs at foes.
I have the current code to do that (not final code, for testing purposes):
...
0
votes
0answers
29 views
Scale Gameobject with defined size in pixels
I'm still new with Unity (5.0.0f4 Personal).
I'm working on a simple memory game, three levels with different number of cards to find pairs. I want my game to display cards on different screen sizes ...
0
votes
1answer
55 views
Unity 2d - Destroying foreign object from script + seek explanation about destroying objects
I have simple emmiter which sending enemies toward player in center of screen. Player can shoot missile (also emmiter). I want to destroy enemy AND missile in same time.
Here is my code attached to ...
3
votes
4answers
292 views
How to enter a level when touching an object
I am working on a project in Unity 4.6.1f1 and I was wondering how can I make a cube touch another cube to go to the next level (the image below)?
!
EDIT: I made a script and put it on the purple ...
1
vote
1answer
199 views
How to move objects in any direction by swiping with libgdx android game development
first of, I'm new to android game development so I don't know all the classes and dictionaries within android and libgdx. I'm actually following a game development tutorial for the first time ...
1
vote
1answer
574 views
Destroying Unity GameObject when it goes out of camera during runtime
I have this GameObject instanciated in unity -
void Start () {
GameObject myRoadInstance =
Instantiate(Resources.Load("car"),
new Vector3(5, 5, 5),
...
0
votes
0answers
49 views
Particle system ONGui()
I have some scripts which uses OnGUI() method and they are attached to my GameMenu object. I need to play a particle system on the scene while the GUI scripts are active. When I do that I cant see the ...
0
votes
1answer
81 views
Check if is object in camera field and not covered by other object
I know how to check if object is in camera view but how I can check if that object is cover by something elese? In my case I want to turn on or off some effect when I look at light. At this moment my ...
3
votes
1answer
63 views
Unity - C# - Overlapping Rectangles not separating
I am Instantiating a lot of Rectangles of different sizes (ranging from 3 to 18 units) and they all have attached this script, which should cycle through all the GameObject List which contains them.
...
2
votes
2answers
842 views
How do I save and restore an int value with PlayerPrefs?
I am stuck on how to save the player's amount of money. When I build the game in the exe as soon as I shutdown the game my money value gets lost. I want this money to be saved. I am using the ...
0
votes
2answers
64 views
Questions about property-centric game object runtime
I was reading Game Engine Architecture by Jason Gregory
So according to him, I should use an array of entities, and arrays for each property, such as an array gameObjectsPosition, ...
0
votes
2answers
49 views
Refer to a gameobject on start
So I want my script to set the initial position of an object depending on the size of the screen and whatever. How do I refer to the gameobject? I know you can modify stuff like their location if the ...
0
votes
1answer
263 views
Help with understanding “transform.root.GetComponent<>” in Unity
I'm reading through a tutorial for making an RTS in Unity, and in certain scripts it wants you to make a Player field and then OnStart(){ transform.root.GetComponent}. I am not quite getting what that ...
2
votes
2answers
119 views
Destroying object from object method
My game uses an entity manager and entities to represent everything including the player, enemes, items, ..everything in the game. In my engine it's the responsibility of every entity to update ...
0
votes
1answer
109 views
Unable to instantiate objects Straight in unity
I am creating a match card game in unity and I want to place cards in straight direction that is one below another and so on... But with my formula It's showing cards one after another.Please tell me ...
0
votes
1answer
178 views
Assigning multiple game objects to a single sprite (Unity)
I've been making a pokemon game clone on my own with Unity, as I'm a beginner and just trying to learn. Up until now I've been splicing the town pictures and manually putting them together, but this ...
0
votes
0answers
190 views
Dynamically destroy objects when player enters a boxcollider2D
What would be the best approach for destroying dynamically objects when player enters a boxcollider2D?
Currently using parent objects with boxcollider2d to activate OnTriggerEnter2D, boxcollider2d is ...
0
votes
0answers
79 views
How do you use Lua with several game objects / components?
I haven't found a lot of information / tutorials on this subject, so I figured I'd ask here.
I would like to use Lua-Alchemy (the Flash port of Lua) to be able to load scripts and run console-like ...
0
votes
1answer
428 views
How can I edit the components of an instantiated prefab?
Is it possible to edit one or more components of an instantiated prefab ?
For example if you instantiated five cube prefabs. Is it possible to reference each of the cube prefab and change a value ...
0
votes
0answers
38 views
Resize gameObject when it has extended a restricted area
So here i have an image will provide a better understanding of my problem.
So currently i have some white blocks and within the white blocks i have some cyan bordered boxes.
So the current problem i ...
2
votes
1answer
366 views
Get object length and width divided by two?
I have googled and found a script for the following task; Make the camera move to touched position. However, this script will jump to x and y positions on an object, while i would like for it to move ...
2
votes
1answer
1k views
How can I access a script variable from another script in Unity?
I'm creating a space shooter (think Space Invaders or Galaga) where the GameManager persists between scenes but the player and enemies don't. I need to access a boolean value from the player and ...
2
votes
3answers
1k views
How do I check whether a camera has unobstructed view of a GameObject?
I want to check if a GameObject is visible to the camera. The renderer.isVisible-method only checks if the camera is turned towards the object, not if there is anything between them (like a wall).
...
1
vote
2answers
196 views
Trying to better understand Unity gameobjects
New to Unity, but develop in C# normally. I can't seem to get how / why / where to grab certain elements. For simplicity, I have a top-level game object, say a cube. I add a sphere to the scene as ...
0
votes
2answers
105 views
Gameobject-Component model with many background tiles - long iteration time
So I'm making a game engine for a game I'm making - the game is a 2D tile-based game
I've implemented a gameobject-component style for the engine, for decoupling reasons
However, every frame, the ...
0
votes
1answer
274 views
Moving gameobject with animation according to my script Unity3D
I am developing a game with Unity3D with an horizontal list of elements which you can move with arrows. Here you can see an example:
I have created animations in order to modify the alpha value of ...
0
votes
2answers
114 views
Manage game objects depending on visibility [closed]
I'm trying to create an adventure game in 2D and I'm thinking about map management/objects.
Here is what I've got in mind in terms of modelling:
Now, I would like to create entities based on ...
0
votes
2answers
221 views
How do I architect around Object Pools?
Example
I have an "Enemy" class, and 5 types of enemy subclasses.
These enemies will be spawn often, so I want to use an object pool.
However, this means I can no longer use an object pool for ...
-1
votes
2answers
455 views
How to stop a object with progress bar so it can start instantly in unity [closed]
I have created a gameobject(cube) and written code to move,mean while the processbar get loading.when the processbar is loaded fully then the object should stop moving.Can anybody please help me ...
1
vote
1answer
2k views
How do I detect a destroyed object in Unity?
I have an object in unity which is spawn through a script. Upon detecting that the object has taken substantial damage, objectDestroy is called and the object is removed.
However, I would like for a ...
0
votes
1answer
7k views
How to enable/ disable GameObject
I have child object with ParticleSystem component.
I want to have particles disabled until I press button.
I unchecked child object to make it disabled but when I press play it enables ...
1
vote
2answers
296 views
collision in different layer
I have a game object called game object 1 on screen. It holds an image called red . when i drag an image called "animal" on a game object 1 collision happening fine and destroys the "animal" in same ...
0
votes
1answer
487 views
Game object position issue in unity3d
I have a set of objects placed on the same layer where all the objects are invisible except one. When I drag an object into a selected area, the current dragged object gets destroyed, and the object ...