Click here to Skip to main content
15,886,806 members
Everything / Unity2D

Unity2D

Unity2D

Great Reads

by DaveMathews
Using an on-device bot development framework to integrate a chatbot into unity
by André Marcos (Advisor), José Cláudio Silva, Victor Lopes
Unity Engine support for Electronic 2D game development
by Simon Jackson
Mastering Unity 2D game development - animation curves

Latest Articles

by André Marcos (Advisor), José Cláudio Silva, Victor Lopes
Unity Engine support for Electronic 2D game development
by DaveMathews
Using an on-device bot development framework to integrate a chatbot into unity
by Simon Jackson
Mastering Unity 2D game development - animation curves

All Articles

Sort by Score

Unity2D 

7 May 2020 by DaveMathews
Using an on-device bot development framework to integrate a chatbot into unity
12 Aug 2023 by OriginalGriff
Spelling: it matters!public Transform spawnPoint; Vector3 spawnPos = spwanPoint.position;
29 May 2020 by OriginalGriff
Start of by learning C# first - ignore Unity until you have the basics done and properly sorted in your head. A course is the best idea - check locally, you may find evening classes - or a book if that isn't available (Wrox, Addison Wesley, and...
11 May 2022 by CPallini
You missed the semicolon at the end of the class declaration. I assumed it was C++, my bad. Please note: Quote: currentScore + normalEnemy; has no effect. Possibly you meant currentScore += normalEnemy;
17 Nov 2022 by André Marcos (Advisor), José Cláudio Silva, Victor Lopes
Unity Engine support for Electronic 2D game development
28 May 2020 by F-ES Sitecore
Does the text output reflect what you would expect? Your fuel system code only sets the max value of the slider if startFuel > maxFuel, are you setting the values in the editor for when that condition isn't true? Also in ReduceFuel you set...
11 Jun 2021 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...
30 Mar 2022 by Dave Kreskowiak
If you don't specify a literal number as a float, it's is assumed to be a double: gameObject.transform.Translate(new Vector2(-0.1, 0.0f)); The fix is easy: gameObject.transform.Translate(new Vector2(-0.1f, 0.0f));
11 May 2022 by Gerry Schmitz
Perhaps what you want is more along the lines of: ScoreScript.currentScore = 0; if (enemyTriangle.tag == "normalEnemyTag") { ScoreScript.currentScore = ScoreScript.normalEnemy; } else if (enemyTriangle.tag == "eliteEnemyTag")...
16 Jan 2023 by OriginalGriff
We cannot help you: partly because it's too major a task for a little text box like this (this is "Quick Answers" after all not "Full Time Mentoring"), and partly we have no idea how far you have got - but it sounds like you haven;t even started...
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...
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...
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...
5 May 2023 by Graeme_Grant
I popped your question into Google Search: How do I scale the gameobject in unity engine automatically according to the screen size, outside the canvas?[^] It gave me this YouTube video: HOW TO SCALE UI TO FIT ANY SCREEN RESOLUTION IN YOUR GAME...
20 Jun 2023 by Richard MacCutchan
Looking at the C# code you have: public void StartSpeechRecognition() { AndroidJavaObject speechResultListener = new AndroidJavaObject("com.example.unityandroidplswork.STTPlugin$SpeechRecognitionResultListener", this); ...
27 Jul 2014 by Simon Jackson
Mastering Unity 2D game development - animation curves
22 Nov 2019 by Member 13925784
I'm creating a game where an admin can ask users questions. however questions will be math equations and the answers that the users give need to be in diagram form. So I am wondering, would it be easier to just allow the admin to submit how the diagram should look, or shall I assign each...
24 Nov 2019 by Afzaal Ahmad Zeeshan
The problem is here: void OnTriggerExit() { ChestText.text = false; } The error says that you are trying to store a value of type boolean, in a variable (property, field, member...) that expects a string value. Luckily, in C# you do a ToString() function call and convert the data to string....
30 Jan 2020 by Richard MacCutchan
java.lang.RuntimeException: Duplicate class com.unity3d.ads.BuildConfig found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:) Duplicate class com.unity3d.ads.IUnityAdsListener found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:) Duplicate class...
28 May 2020 by CodingGreek
I'm a beginner learning to code with Unity as well. I want to set up a Fuel System so that when the car moves the Gas is used up. But my UI slider (that shows the fuel gauge) just doesn't seem to be working. Please help on the below 2 scripts: ...
29 May 2020 by CodingGreek
I want to learn C # and Unity together but I am new to programming and I would like to know the best ways there are. Maybe a website, videos or even a book that could help me out in anyway. I am new to programming and already I'm understanding a...
12 May 2021 by HardykMahendru
Hey, I am making a player script in unity to display it’s health and power-level. Though I am getting the desired output but can someone explain what the above problem is about. here is the code:- int health = 100; int power = 0; ...
12 May 2021 by OriginalGriff
What you have written is a constructor: public Player() { Debug.Log("health is " + health); Debug.Log("power level is " + power); Debug.Log("the name of the player is " + name); } Constructorts are the only...
19 May 2021 by OriginalGriff
Text is a type - otherwise this line would not compile: public Text scoreText; So this line: scoreText.text = Text; Tries to set a value but Text has not been declared as a variable anywhere in scope. Hence, the closest it can come is to find...
11 Jun 2021 by BillWoodruff
Describe the context here: is this a Unity app, or, are you controlling some device that exposes an API ? Where is Mathf.Lerp defined ? Add tags to your question to help readers quickly know what the context is. Can't say much based on this...
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"]: ...
9 Sep 2021 by Nils Leonhardt
Hello, I'm trying to create a short 2D game where you can wait x amount of time to get for example 50 "troops". This for now works fine, but now I need a script that detects the number of troops I have (at the startpoint) and send them out, just...
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...
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...
29 Oct 2021 by Lemons and Giggles
i have two guns and two different functions for it. i want that gun to shoot which I have picked. but even other guns is shooting that I haven't picked so someone please solve this issue. public class weapon : MonoBehaviour { public...
30 Mar 2022 by Deidara 2.0
using UnityEngine; using System.Collections; public class Movimento : MonoBehaviour { public Animator Animacao; // Use this for initialization void Start () { } // Update is called once per frame void Update ()...
11 May 2022 by Soraaaaaaa
It keeps giving me the semicolon error but I have every statement ended with a semicolon. using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bullet : MonoBehaviour { void OnCollisionEnter2D...
11 May 2022 by Soraaaaaaa
First and foremost, these are my codesusing System.Collections; using System.Collections.Generic; using UnityEngine; public class Bullet : MonoBehaviour { public GameObject enemyTriangle; void OnCollisionEnter2D (Collision2D collision) ...
31 Aug 2022 by OriginalGriff
The error message means exactly what its says: you have tried to access an element of a collection that doesn't exist because the index is invalid. In C#, indexes run from 0 to (N - 1), when N in the number of elements in the collection. So for...
31 Aug 2022 by CPallini
Quote: public void ButtonNext() { index += 1; //
8 Sep 2022 by m0r yana
i want to save prefab between the scenes, it is something like inventory, and i have this: Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false....
8 Sep 2022 by OriginalGriff
Read the error text again - it tells you what to do: Quote: Consider using the SetParent method instead, with the worldPositionStays argument set to false. It even tells you why ... Quote: This will retain local orientation and scale rather than...
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 =...
18 Dec 2022 by Richard MacCutchan
You have not explained which line gives the error, but I assume it is at the end of the IdleFarm method. The method declaration is IEnumerator IdleFarm(), so the compiler expects it to return something at the end. But you have nothing at the end...
20 Jun 2023 by CheesePotat0
I created a Java plugin to include speech recognition in my Unity Android game. It is activated by touching a button onscreen, and when the button is released, the audio is processed. This feature isn't working, and checking the game logs I found...
20 Jun 2023 by CheesePotat0
I keep on getting this same error each time I test my game and I don't even know where it is being generated. This is the related code Java plugin package com.example.unityandroidplswork; import android.content.Intent; import...
20 Jun 2023 by Richard MacCutchan
See your repost of this question at Unity android plugin exception JNI unknown argument type 'speechrecog'[^].
26 Jun 2023 by CheesePotat0
I'm including voice commands for my Android game in Unity. The speech recognition is triggered via button, and the recognized command is supposed to be shown on a TextMeshPro onscreen. At first it looks like it's working, but the TextMeshPro...
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...
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...
13 Dec 2023 by Member 16162039
Use an empty UI gameobject and let the canvas do the math, set the desired gameobject (non UI) position to this UI empty gameobject via script :)
8 Sep 2021 by Richard Deeming
Your code is decrementing x. Consider what happens in the two possible cases: Option 1: x is greater than -26: x == -25 x = x - 3 == -28 -28 > -29, so the position is increased by 3: x = x + 3 == -25 x == -25 x = x - 3 == -28 -28 >...
3 Oct 2022 by Qasim Ali Oct2022
I have an issue which I don't know where to start to solve I have to make PDF data file using unity c# in webGL build I already done this with HTML but is there any way I can do this with unity C#. What I have tried: I tried some basic threads,...
16 Jan 2023 by Code Wire
Hello Friends.. I need your help I m making a gambling game this is my university project ..so I don't know where I can start ..this is a multiplayer game I don't know about multiplayer game environment & coding so guys kindly help me to write...
11 Jan 2022 by ALEKS • DESIGNS
Hey so as mentioned yhe bullet should follow the enemy till it hits it. I will appreciate if someone could help me Here my Bullet script: using System.Collections; using System.Collections.Generic; using UnityEngine; public...
5 Sep 2022 by m0r yana
In Unity, Who knows?? Somebody did that? What I have tried: -nothig -------------------------------
18 Dec 2022 by Михаил Шпак
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; public class Ahivments : MonoBehaviour...
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; ...
24 Nov 2019 by 95Muffin
Here's the script I have on Unity using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PlayerMovement : MonoBehaviour { public float speed; public Text ChestText; Animator anim; public bool CurrentChest; ...
30 Jan 2020 by Oleg Pruh
Hi, I work in Unity 2018.4.16f1 (64-bit). Today I had to build my project in Grudle, but there is a problem. Help me as soon as possible. Please do not write much, but to understand, you can write a solution step by step. 1 exception was raised by workers: See the Console for details. ...
19 May 2021 by Tsuki Harako
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class yes : MonoBehaviour { public Text scoreText; // Update is called once per frame void Update() { ...
11 Jun 2021 by Blank Channel
NullReferenceException: Object reference not set to an instance of an object MultipelCamera.Zoom () (at Assets/MultipelCamera.cs:36) MultipelCamera.LateUpdate () (at Assets/MultipelCamera.cs:30) What I have tried: using System.Collections;...
8 Sep 2021 by Lemons and Giggles
when I command or set an enemy to go left and then at reaching a particular state or position I say my enemy to go right but it is not going right and not reaching to perfect position here is the code I think there is no issue in the code but it...
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...
26 Jan 2022 by MMT - ElectriX
So basically, a user is gonna type in the hours in an inputfield and I'm gonna get the amount they write as an int in my code. public InputField hours, minutes; public int wantedHours, wantedMinutes; Basically what I want is that people are...
26 Jan 2022 by MMT - ElectriX
THIS WORKED FOR ME: string wantedHoursString = hours.text; if (int.TryParse(hours.text, out int result)) { wantedHours = result; } string wantedMinuteString = minutes.text; if...
31 Aug 2022 by m0r yana
Trouble!!! Help index was outside the bounds of the array cs:33 What I have tried: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ComodScript : MonoBehaviour { public...
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: ...
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...
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...
7 May 2023 by arpitsrivstva
I want to consider the edges/borders of the screens and place the gameObject accordingly with sufficient padding across those edges/borders of screens. Also I have to keep the scale(x & y) equal. I have to prevent it from being bigger or smaller...