Instantiate with parameter not working
Explain me this DARK magic why is this not working ang giving me error: //Ignore random spawn position in instantiate its not relevant GameObject ship = Instantiate(spawnableShip_01,new...
View ArticleChoose random from given numbers
Is there some function in C# like: var randomN = choose(1,5,10,15); Let`s say. I need to specify those numbers. Some simple function please. Random.Range() is not what I need. **REASON:** **I need to...
View ArticleWhy isn`t my 2D AddTorque working?
Hello I have this C# script attached to player in Fixed Update: rigidbody2D.AddTorque(Input.GetAxis ("Horizontal") * 5f); It just won`t work. AddForce works and everything else in that script just not...
View ArticleArray not working
I have no idea what to do. Pls help. private float[] size_itemNeeded; void Start() { size_itemNeeded = new float[3]; //And it just throws array out of index exception here. size_itemNeeded[1] = 2f; } I...
View ArticlePass C# script as parameter to function
Okay I have two or more scripts in separate objects that do the same. (Complex checking inventory system checking if the clicked Button has item in it) What I need to do is make one static function...
View Article2D AddTroque towards Mouse Position
Hi I want my sprite object with rigidbody2D to rotate towards mouse. I need to rotate Top Down SpaceShip. So I can`t use rotation function to rotate sprite instantly. it has to slowly accelerate and...
View ArticleJagged / Pixelated edges on all sprites
Hi (Before I start I`m talking about **2D Sprites** not Textures) My 2D sprites made in adobe illustrator look horrible jagged and pixelated when are not in exactly horizontal and vertical position. So...
View ArticleSmooth 2D camera zoom
Have 2D Top Down game. I need some Smooth Ortographic Camera zoom in it. So far this is not working, it`s pretty fast and not smooth. camera.orthographicSize = Mathf.Lerp(camera.orthographicSize,...
View ArticleLSet length of Line Renderer
How do I set the length of linerenderer??? gameObject.GetComponent().SetPosition(0, new Vector3(0, distance, 0));\ distance is getting right number from the raycast2D. But when I put it here, the line...
View ArticleRaycast2D problems
Hi, Why the following code isn`t working? Vector2 direction = transform.TransformDirection(Vector2.up); RaycastHit2D hit = Physics2D.Raycast(transform.position, direction); if (hit.collider.tag ==...
View ArticleRaycast2D Stops at first object
Hi I have this script, but the RayCast2D stops at the first object it is inside (Mining laser attached to SpaceShip), so it basically stops at Spaceship. Vector2 direction =...
View ArticleEmit ParticleSystem from given Position
Hi I have gameobject. It has attached particle System. I want to do lets say it will spawn its particles on given position. Lets say I get the reference to that particle system by: ParticleSystem...
View ArticleParticle System size problem 2D
I use particle system for my laser when it collides with target. (2D setup) It works very much fine. I Instantiate particle system first with given weapon, and then move it to position and activate it...
View ArticleRunning more scenes in the background
Hi, How would I go about running more scenes in the background? Let`s take X3 space series into example. You have many systems, and you can trade from those systems, watch ships move there, even...
View ArticleIsTrigger Collider2D - horrible FPS drop.
Hi there. I have Polygon Collider 2D on my enemy Sprites on Is Trigger. However, once two or more objects collide with each other, and one of them has Is Triggered (So they are inside each other) the...
View ArticleIs this the best for performance?
Hello, I need to have health bars above enemies. There is a LOT of enemies in the map and I need the most optimized solution. I want to enable the OnGUI only when the camera is near enough to those...
View ArticleBackground Image in 2D
Hi, I want to make a background image, for example in 2D where there is starfield behind the ship. All the help I found on Answers is to create GUI texture... etc which doesn`t exist anymore. Do you...
View ArticleOptimizing thousands of game objects
Hi there, Since I have started to develop my game, it went well, but now performance is my greatest enemy. Game is 2D top down space game. I can generate systems (everything in one scene) but the...
View ArticleTransform.parent changes rotation/position 2D
Hi I am creating many 2D objects and I need them to be parent of the main Object_Spawner let`s call it so the hierarchy is clean. GameObject planet = Instantiate(planet_GameObject, pos,...
View ArticleLoop through partially filled Array of Objects
Hi I have game, it has many objects 500+, I store each created objects in this array and remove from array the objects that are destroyed. Now my Question is: How do I loop through this array/database?...
View Article
More Pages to Explore .....