Click here to Skip to main content
15,886,258 members
Everything / Game Development / Unity

Unity

Unity

Great Reads

by Akhil Mittal
A tutorial to learn dependency injection with the help of a simple example
by Byte-Master-101
In Part 2, the Neural Network made in Part 1 is tested in an environment made in Unity so that we can see how well it performs.
by Alexander SchuIze, Felix Herbst, Paul Kirsten
Multi-User game for AIO where players build their own spider's web
by Joel Ivory Johnson
In this article I take a look at setting up a system for HoloLens development, the compatibility of the applications with other UWP platforms, and introduce Unity for making a 3D application

Latest Articles

by EgorYusov
This article describes Unity low-level plugin interface and the Unity graphics interface emulator that facilitates native plugin development.
by André Marcos (Advisor), José Cláudio Silva, Victor Lopes
Unity Engine support for Electronic 2D game development
by OwenDavies
Installing a desktop environment and setting up RDP to allow us to connect to our Virtual Machine
by DaveMathews
Using an on-device bot development framework to integrate a chatbot into unity

All Articles

Sort by Updated

Unity 

14 Feb 2024 by Hailu Worku Obsse
Your script looks good for the most part. However, there are a few things to consider and potentially improve: Input System Integration: You're currently using the legacy Input.GetKeyDown(KeyCode.E) and Gamepad.current to detect input. It's...
12 Feb 2024 by Andrew Akram
I have this code here that displays a game object when I press E on the keyboard the only issue is it works with the host and nothing happens when the client interacts with it when he presses E. what is the solution or what I'm doing wrong and...
2 Jan 2024 by Elinor Gal
jkhlkjl';' l' ' ';k;'l' ;k;'k;'l;l';l';jl;jlkhj What I have tried: urtfyu654768789w74356utgyzthrjyukdtyghdtyduydgykdgyedjyd
31 Dec 2023 by OriginalGriff
You get an index out of range error when you try to access an array element which doesn't exist. In C#, arrays are zero based, so an array of N elements with have valid indexes between 0 and (N - 1) only: an array of three elements such as this:...
5 Dec 2023 by Dylin Messick
using System.Collections; using System.Collections.Generic; using UnityEngine; public class SwimmingController : MonoBehaviour { public float swimSpeed = 5f; // Adjust the swimming speed as needed public Transform leftHandController; //...
5 Dec 2023 by Dylin Messick
using System.Collections; using System.Collections.Generic; using UnityEngine; public class sswimmingController : MonoBehaviour { public float swimSpeed = 5f; // Adjust the swimming speed as needed public Transform (leftHandController);...
5 Dec 2023 by Dave Kreskowiak
variable names cannot have parenthesis in them, so get rid of the parenthesis: public Transform leftHandController; // Reference to the left hand controller public Transform rightHandController; // Reference to the right hand controller ...
4 Dec 2023 by Richard MacCutchan
public Transform (leftHandController); // Reference to the left hand controller public Transform (rightHandController); // Reference to the right hand controller Remove those parentheses from around the variable names.
4 Dec 2023 by Maciej Los
To resolve your issue, please, read this: Compiler Error CS1001 - C# | Microsoft Learn[^]
13 Sep 2023 by 3DARVR ds
using System.Collections; using System.Collections.Generic; using UnityEngine; public class QuizManager : MonoBehaviour { public List QnA; public GameObject[] options; public int currentQuestion; public Text...
3 Sep 2023 by sathishKumarsubramani1
Add "Using UnityEngine.UI" and it resolves the issue. Hope you have the correct version of UnityEngine refrence. Link :https://docs.unity3d.com/2017.3/Documentation/ScriptReference/UI.Text.html
3 Sep 2023 by FreedMalloc
The error message tells you exactly what is wrong. It can't find a thing called 'Text'. It even asks if you're missing a using directive. The video you referenced even shows the using statement you need being added when the object is added on the...
13 Aug 2023 by Mus_ 90YT
So when trying to install one version of unity in unity hub, the last 2 files are bugged; -Android NDK: Freezed at 22% -CMake: Download failed: Validation Failed Even tho I've restarted the failed downloads nothing has changed. I'm scared...
13 Aug 2023 by Andre Oosthuizen
This seems to be an issue all over, have a look at these 2 links which has some kinds of solutions - "Installing..." is taking forever, unity hub[^] Unity Hub SDK and NDK tools download freeze[^]
13 Aug 2023 by OriginalGriff
We can't help you - we have no access to your systems, or any clue what is happening at the Unity end. Try here: Unity Customer Service: Technical Support & Training | Unity[^]
13 Aug 2023 by Mus_ 90YT
Hello. So when I finished my game in unity, everything worked. But when I tried to build the apk... got this 4 errors; UnityException: Android SDK not found Unable to detect SDK in the selected directory. C:\Program...
13 Aug 2023 by OriginalGriff
Try exactly what it suggests: Quote: Unable to detect SDK in the selected directory. C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\latest\bin\sdkmanager.bat does not exist. Android SDK...
12 Aug 2023 by Mus_ 90YT
Hello there! So I’m new into making games, I’ve just done a fev python projects but never in any other software than html. Now I’m interested in creating games, and what better than start making a 2D Android game? So I’m just half copying a...
12 Aug 2023 by OriginalGriff
Spelling: it matters!public Transform spawnPoint; Vector3 spawnPos = spwanPoint.position;
12 Jul 2023 by EgorYusov
This article describes Unity low-level plugin interface and the Unity graphics interface emulator that facilitates native plugin development.
5 Jul 2023 by OriginalGriff
We can't tell - it's likely to be something just above the code fragment you show that is causing the error, and we can't see that. This may help: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^] [edit] BTW: do...
5 Jul 2023 by Bryce Walker
I'm a beginner learning from youtube. I followed the tutorial code exactly but got this error. error CS1002: ; expected my code: if(!Camera.main) { Debug.Log("Unable to find main camera"); return; } It says the error is at the...
4 Mar 2023 by User204
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class player_good : MonoBehaviour { public float speed ; public float JumpForce; ...
4 Mar 2023 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
25 Feb 2023 by User204
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class player_good : MonoBehaviour { public float speed ; public float JumpForce; Rigidbody2D rb; bool...
24 Feb 2023 by OriginalGriff
To add to what Richard has - rightly - said ... You should expect to get syntax errors every day, probably many times a day while you are coding - we all do regardless of how much experience we have! Sometimes, we misspell a variable, or a...
24 Feb 2023 by Richard MacCutchan
Well a quick count down to line 56 reveals: else (collision.gameObject.Comparetag=="end") Which is obviously incorrect, as the part after the else is a conditional expression. It should be: else if...
20 Dec 2022 by Haunter Plays
In Unity i am getting 'Tiletype' is inaccessible due to its protection level in the following underlined lines Relevant C# Script: using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class...
20 Dec 2022 by OriginalGriff
Chris is almost certainly right and has given you the solution. But, I'd just like to add a bit of background: You should expect to get syntax errors every day, probably many times a day while you are coding - we all do regardless of how much...
16 Dec 2022 by Wooden Cars
How to: If the text is 10 then gameobject deletes? using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class UnityCollectItems : MonoBehaviour { public...
16 Dec 2022 by Richard MacCutchan
Unity has a dedicated forum at Unity Forum[^]. You will likely get help faster from there.
17 Nov 2022 by André Marcos (Advisor), José Cláudio Silva, Victor Lopes
Unity Engine support for Electronic 2D game development
31 Oct 2022 by Mae Spencer
Hi! I am working on creating a big project and need some help with two functions. I need to create a function that does the same thing as Linq, Append and Distinct without using Linq or Lists. If you are able to help me out I would greatly...
31 Oct 2022 by Richard Deeming
First up, your AddToArray code is wrong. You copy the empty returnarray to the passed-in garray array. You then copy the empty returnarray to the single-element newarray array. Both attempts to copy will result in an ArgumentException: ...
30 Oct 2022 by jcjms
I started using PlayerPrefs in Unity and everything worked perfectly. Then I tried to build the game to send it to a friend. *But* as I tested it one more time (build version). The PlayerPrefs stopped working. It's just, like they never existed....
30 Oct 2022 by OriginalGriff
Restarting won't help: the error is saying that the string you have provided does not contain a valid number. So look at the code, and find line 123 of file UI_Inventory.cs: it's probably this one: item.amount =...
28 Oct 2022 by OriginalGriff
That's a really inefficient way to do it: a List maintains an internal array which when it it full it allocates and copies into an new array twice the size. That's way, way more efficient than what you are doing - have a look here and see how...
23 Oct 2022 by Member 14769677
I am writing a game in Unity where I need to convert a TextMeshProUGUI text into a float, but for some reason this code: float num = float.Parse(inputText.text); Gives me this error: FormatException: Input string was not in a correct format....
23 Oct 2022 by OriginalGriff
We can't tell: it need your code running in context with your inputs to find out. Certainly for me, an input of "1" gives no exception: using System; public class Program { public static void Main() { string input = "1";...
21 Oct 2022 by Member 13745684
I am trying to build a first person mobile game and i need some assistance. I am having some issues with my mobile joysticks. I have 2 joysticks, one for movement and one for the camera. The camera joysticks is not working, and the movement...
25 Sep 2022 by Mackenzee Ferren
This is the code and Nothing will move. I know it's something I have done because everyone else says it works fine. using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class PlayerMovement :...
25 Sep 2022 by OriginalGriff
If you got the code from a YouTube video, then go back there and ask him. Chances are that it never worked; that he doesn't know why; that he can't fix it - so he won't reply. In that case, dump it, and look for better code that does. Remember,...
17 Sep 2022 by m0r yana
I have 2 scenes. im trying to take an object from 1 scene and trigger it with another object on scene2, it doesnot work, but if two objects are on one scene it works, why? who knows? and i also want to trigger definite object What I have tried: ...
5 Sep 2022 by m0r yana
In Unity, Who knows?? Somebody did that? What I have tried: -nothig -------------------------------
14 Jul 2022 by John fitzpatrick 2022
Assets\Scripts\InputHandler.cs...
14 Jul 2022 by Dave Kreskowiak
You will not find a fix for this anywhere on the web. This is a problem where you're trying to execute a method or property, "PlayerMovement", on a "PlayControls" object that does not exist. If you're running into this from a book or something,...
11 Jul 2022 by Kitbosss
So, basicly I want to do something, but it doesn't work. I wanna reference a GameObjekt, but don't know how. I want to make "player" the same as "vehicle" is that possible? or make that "player" means "vehicle" Here's my code: using...
11 Jul 2022 by Gerry Schmitz
It's "GameObject"; not GameObjekt. Unity - Manual: Important Classes - GameObject[^]
11 Jul 2022 by OriginalGriff
I think you probably need to do two things: 1) Learn C# and how it works pretty well before you start with Unity development - y6our question shows that you don't understand objects, instances, or inheritance at all, and you need to know that...
11 Jul 2022 by TheRealSteveJudge
Your code snippet does not seem to make any sense. Please have a look at their documentation: Unity - Scripting API: GameObject.Find[^] There is even a tutorial! Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, &...
7 Jun 2022 by Bl4ugr4n4 Bl4ugr4n4
using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyVision : MonoBehaviour { private Enemy enemyScript; public GameObject playerCenter; public float range = 5.2f; public float...
20 May 2022 by NoobZee
I am getting following errors; No Overload for Method SetTopColor And "foreach statement cannot operate on variables of type 'Block' because 'Block' does not contain a public instance or extension definition for 'GetEnumerator'" My code is...
20 May 2022 by OriginalGriff
What you need to do is stop trying to run before you can walk: you need to understand C# rather better than you do at the moment, and certainly understand it pretty well before you start playing with Unity! The first error is pretty explicit:...
24 Apr 2022 by pay pal 2022
Please read before this question is reported / taken offline! This question has already been taken offline on StackOverflow and I was pointed to the resolution of a general NullReferenceException. But these solutions somehow don't work for me 😥....
24 Apr 2022 by OriginalGriff
Answered only to remove from unanswered queue: solved by OP (with help from Richjard)
17 Mar 2022 by Mark Kidder
I am trying to cast a Raycast and hit another player that causes text to say that the player has been hit. It wont register hitting another player, but it registers when it hits itself. Here is the code for the character shooting script, which...
12 Mar 2022 by yash bhole
I am having problem finding a code to import data from thingspeak to Unity, for my project. Please help if possible. What I have tried: I have tried looking on github and stackoverflow.
18 Jan 2022 by CodeSie Programming
I have tried so many packages, none of them work as WAN. They all just work as LAN and looking it up they say you need to do port-forwarding on your router and all this kind of stuff. In my mind, atleast, it's IMPOSSIBLE this is how an...
5 Jan 2022 by imbruceter
I want my gameobjects to fall faster by time as the player collides with them. What I mean is, when the game starts, the gameobjects fall off after 1 second the player collided with them, but after 60 seconds, gameobjects only fall after 0.3...
22 Dec 2021 by Ninja Boy
I had made a C# script in unity about dashing my character here is the script . public class Dash : MonoBehaviour { Movement Move; public float DashSpeed; private float DashTime; // Start is called before the first frame update ...
22 Dec 2021 by OriginalGriff
First off, C# is case sensitive: so Movement is not the same as movement. You first example code uses both, so one of them will be wrong: Movement Move; ... void Start() { Move=GetComponent(); } The second example tells the...
18 Dec 2021 by imbruceter
Gameobjects are getting randomly spawned on some platform objects. I want to avoid these two different gameobject to be spawned at the same exact location (money2 should change it's position). Here is the code: void Start() { ...
18 Dec 2021 by Ron Nicholson
I have used unity a little bit. So take this with a grain of salt. You are only instantiating an object when your random number is 0, in both cases. How many object will be created at one time. will you have up to 15 objects or only the two? ...
12 Dec 2021 by Denis Hristov
Hey, I'm making this Sudoku in Unity3D project and I'm currently stuck on making the application check whether or not there are duplicate values in the specific row and column where the number has been inputted. I can provide the GenerateGrid...
12 Dec 2021 by Gerry Schmitz
I assume you know how to iterate an array. In which case, if you use a Dictionary or List to "count" while iterating, you'll know when you have a duplicate (i.e. no existing entry, add the entry; if existing, it's a duplicate.)
6 Dec 2021 by Denis Hristov
I am trying to make a Sudoku game in Unity3D but I'm currently stuck on the logic behind the game. (checking if all the numbers in the same subgrid, row and column are different) I have been able to get a script that generates the whole grid...
23 Nov 2021 by Johny Pikolino
using UnityEngine; public class PlayAudio : MonoBehaviour { public GameObject audioObj; public void DropAudio() { Instantiate(audioObj, transform.position, transform rotation); } } What I have tried: Just say what is...
23 Nov 2021 by phil.o
Try Instantiate(audioObj, transform.position, transform.rotation); ^ You may want to follow a basic course on C#, as it is pretty standard stuff which you should be able to spot by yourself....
23 Nov 2021 by OriginalGriff
Look at your code: Instantiate(audioObj, transform.position, transform rotation); ^ | I'm pretty certain that should be a '.' not a space ... ...
23 Oct 2021 by ThunderWiring
I'm building a C++ plugin for a Unity Android app. The plugin is using OpenCV and specifically i need to load a caffe model by using: cv::dnn::readNetFromCaffe(path to model files) Problem is, the plugin is a dll file, so what is the...
27 Sep 2021 by Ethir Pakalela
hi there, This below code works absolutely fine : the DRAG AND DROP function works good. Here when correct image is droped on to its correct place it stays , but how to lock the image once its dropped in its correct position? using...
27 Sep 2021 by Pete O'Hanlon
There are many ways you could achieve this. You could, for instance, maintain a HashSet of animals that have been dragged like this:private HashSet _draggedAnimals = new HashSet Having done this, you would need to do two...
22 Jul 2021 by Member 14052464
I encountered an issue, I am unable to get the package from Git to Unity, I get this error message: Package Manager Window] Unable to add package ["com.unity.2d.tilemap.extras": "https://github.com/Unity-Technologies/2d-extras.git#master"]: ...
20 May 2021 by Member 15134456
Recently I am making a UI asset for Unity. I used Unity 2020.1.0f1 for making and testing primarily. I now have a project in Unity 2021.1.3f1 and I want to use my UI asset. This asset is a unitypackage and contains 3 DLLs (1 C# DLL, 2 C++/CLI...
18 May 2021 by Member 15205567
Full Error: Assets/Scripts/CameraManager.cs(89,9): error CS1955: Non-invocable member 'CameraManager.cameras' cannot be used like a method. using System.Collections; using System.Collections.Generic; using UnityEngine; public class...
18 May 2021 by Dave Kreskowiak
You keep doing this: cameras (currentCamera).enabled ... when cameras is a collection, and you need to use its indexer like this: camera[currentCamera].enabled ...
10 May 2021 by cyma_1
HI, I want to test my fps controller game with unity3d, but when connected to remote the character controller head rotation is not working neither in remote device or pc. how to fix this? any help will be grateful. Using unity 3d Version...
27 Apr 2021 by OriginalGriff
No. Nobody here is going to provide you with credit card information or do this for you. Instead look to see if you can find an "prepaid debit card" that you can apply for.
6 Apr 2021 by Cody O'Meara
I have been working on a Unity game for a bit. The database is MySql. I want to create a link between the unity server I have and the website server. So I have an array of servers for my game already. I have another server that I installed...
6 Apr 2021 by Chris Copeland
This is an example of distributing databases and having them synchronise. It's a common practise for applications with enormous user bases (ie. YouTube) to optimise for speed, by having multiple databases available for reads and writes, and...
9 Mar 2021 by KEEPREADING
I am looking to build a Children’s educational app for alphabets, numbers, phrases, words etc. I want to use a cross platform framework that can create good 2D graphics and animated videos. Could you kindly suggest any cross platform frameworks I...
9 Mar 2021 by Richard MacCutchan
See Xamarin.Essentials - Xamarin | Microsoft Docs[^], but you need to be a reasonably experienced programmer.
18 Feb 2021 by Spoiled Nut
this is the console error from unity [11:27:31] Assets\WanderingAI.cs(44.17) Error CS0116: a namespace cannot directly contain members such as fields or methods The code i use is here using System.Collections; using System.Collections.Generic;...
18 Feb 2021 by Jon McKee
The lone '}' after the Update() function closes the class definition, therefore Wander() is a method defined directly within the namespace, hence the error. Move that '}' to the very end of the code you posted and that error should go away.
1 Feb 2021 by Michael Ciurleo
So I'm making an ai for a tank game but instead of the tank moving smoothly, it just skids around in one direction when it should be moving around the map independently as well. how do I fix this? Here is the code: using System.Collections; using...
1 Feb 2021 by Gerry Schmitz
When your minimum and maximum are both the same, how do you expect to get any "range"? float posMin = 50f; float posMax = 50f;
22 Jan 2021 by Mackenzee Ferren
using System; using UnityEngine; public class CameraLook : MonoBehaviour { public float mouseSpeed = 100f; public Transform playerBody; float xRotation = 0f; void Start() { Cursor.lockState = CursorLockMode.Locked; ...
22 Jan 2021 by Christian Graus
Clearly the rotate method doesn't know what your variables are called. I think you need to make this your second parameter Unity - Scripting API: Transform.Rotate[^]
12 Jan 2021 by Member 15044276
i wrote a script to manage my Particle System emission. The starting lifespan is set to infinite so that the particle never dies until it reaches a specific collider. here's the code using System.Collections; using System.Collections.Generic;...