Click here to Skip to main content
15,888,454 members
Everything / Unity3D

Unity3D

Unity3D

Great Reads

by LLLLGGGG
In this article, I am going to explain how to generate a hexagonal tessellation and how to draw it in Unity 3D
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
by IAmJoshChang
Attacking enemies, health system and death animation in Unity
by EgorYusov
This article describes Unity low-level plugin interface and the Unity graphics interface emulator that facilitates native plugin development.

Latest Articles

by EgorYusov
This article describes Unity low-level plugin interface and the Unity graphics interface emulator that facilitates native plugin development.
by Grasshopper.iics, Abhishek Nandy, Moumita Das
Virtual Reality with Unity, Intel Edison and MQTT
by Dev Leader
How to get all the painted tiles on a TileMap when building a 2D game in Unity3D
by DaveMathews
Using an on-device bot development framework to integrate a chatbot into unity

All Articles

Sort by Updated

Unity3D 

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...
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 :)
12 Jul 2023 by EgorYusov
This article describes Unity low-level plugin interface and the Unity graphics interface emulator that facilitates native plugin development.
2 Jul 2023 by Sandeep Mewara
As error shares, you are calling a non-static item as a static. You can solve this by: Option 1: Have OceanE as static class such that you can directly access it's properties. This depends on the design choice. Option 2: Initialize OceanE...
2 Jul 2023 by Eric Taylor 2023
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering.HighDefinition; public class Floating : MonoBehaviour { public Rigidbody rb; public float depthBefSub; public float...
2 Jul 2023 by Graeme_Grant
Best place to ask Unity questions is here: Unity Support Forums[^]
2 Jul 2023 by Eric Taylor 2023
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering.HighDefinition; public class Floating : MonoBehaviour { public Rigidbody rb; public float depthBefSub; public float...
2 Jul 2023 by Graeme_Grant
I don't do Unity, however, that error in C# usually means that you have not initialised the class before using it. Somewhere in your code you need to create a reference: private OceanE oceanE; and then initialise it: OceanE = new oceanE(); ...
29 Jun 2023 by Sandeep Mewara
If you debug, you will see the error is being raised from: void Update() { currentTime -= 1 * Time.deltaTime; if (currentTime = 0) { OnEnemyspawn(); } } This is because you have written currentTime = 0 in the if...
29 Jun 2023 by Eric Taylor 2023
using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyTimer : MonoBehaviour { public float currentTime = 0f; public float startingTime = 10f; public delegate void Enemyspawn(); public...
29 Jun 2023 by Dave Kreskowiak
In C#, an assignment uses one =, while an equality comparison uses two, ==.
20 May 2023 by Grasshopper.iics, Abhishek Nandy, Moumita Das
Virtual Reality with Unity, Intel Edison and MQTT
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...
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...
17 Apr 2023 by Member 15849100
PHP Code for Update Data in MySQL Database - Tuts Make Step 1 - Connect to MySQL database. Step 2 - Fetch data from the database. Step 3 - Update data from database.
1 Feb 2023 by Karthika Ramachandran 2023
Can I add a button in HTML to allow users to upload external folders from their computers and transfer that data within the Unity WebGL canvas for 3D volume generation? I've developed a button in HTML that allows users to upload files, but I...
23 Jan 2023 by Dev Leader
How to get all the painted tiles on a TileMap when building a 2D game in Unity3D
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 =...
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...
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,...
18 Jul 2022 by Member 11391151
I want to call function from other script but the game objects defined are not loaded.And gives error NullReferenceException: Object reference not set to an instance of an object My code..i am calling executemyoperation() function..It does calls...
31 May 2022 by Richard MacCutchan
for (int j = 0; j
31 May 2022 by simple world
I have 2 arrays, Deffenders and Attackers. I iterate through the arrays and set the NavMeshAgent destination of the Deffenders to each Attackers position. That all works great. The problem is that if i have more Deffenders than attackers then i...
26 May 2022 by simple world
How can i achive the following? .Create points around player. .In these points enemies will fill them, 1 point 1 enemy and so on. .The rest of the enemies should go idle and wait. .If 1 enemy dies then the idle enemy closest to the point should...
28 Apr 2022 by Maciej Los
If i understand you well... Try this: Console.WriteLine($"true = {Convert.ToInt32(true)}; false = {Convert.ToInt32(false)}"); //prints: true = 1; false = 0 So, if you want to return boolean value out of int function, use 0 or 1. ;) int...
28 Apr 2022 by Antonio_Rodrigues
I was asked to make a function int return bool and I can't find a solution, I though you can't return bool in a function int. I just need to know if is posivel. What I have tried: I tried to search everywhere but I couldn't find a solution and...
28 Apr 2022 by OriginalGriff
Something like this: private bool Foo(int x) { return x == 666; }
28 Apr 2022 by Antonio_Rodrigues
The function instead of receiving as input parameter a parameter of type int which will receive an array of ints and a int number that we will call b. The end of the function will be to return true or false in case some or all of the numbers in...
28 Apr 2022 by Patrice T
Quote: I can understand this ex my teacher gave me Programming is the art of details, You have to read carefully the requirement and find the logical order of every little pieces in order to make sense of it all. As is, your code is nowhere near...
28 Apr 2022 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
28 Apr 2022 by Richard MacCutchan
if (numbers[i] / b == 0) You are checking if the answer is zero, but your question needs the remainder after the division. You should use the modulo operator: if (numbers[i] % b == 0)
26 Apr 2022 by Antonio_Rodrigues
I don't know why, but the error are in the returns. public class funcoes : MonoBehaviour { int testSumArray(int[] numbers = null, int b = 2) { numbers = new int[] { 8, 3, 9, 6, 7, 4 }; int conta = 0; for(int i =...
26 Apr 2022 by Patrice T
Don't know what you intend to do with this code, but here is a possible correction : public class funcoes : MonoBehaviour { int testSumArray(int[] numbers = null, int b = 2) { numbers = new int[] { 8, 3, 9, 6, 7, 4 }; int...
26 Apr 2022 by Dave Kreskowiak
You can Google this all you want. You'll never find the answer, and you don't need to. You just need to look at your own code. Where do you define the return type of a method? What does that say? | | v int testSumArray(int[] numbers = null,...
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)
4 Apr 2022 by PVP CODE 001 SAHA
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerShoot : MonoBehaviour { public PlayerController PlayerController; public Camera camera; public float damage; public float...
4 Apr 2022 by k5054
You have public float canShoot = true; . So you've declared a member variable to be of type floating point, but then try to assign a boolean value (i.e. true) to it, which makes no sense. It's like declaring a member of type 'color' and then...
26 Mar 2022 by Brownie's Adventures
I made a first person camera using parts of Brackeys Guide, but I have camera moving on both the axis but the line for the xRotation clamp doesnt work when I run the game. How can I fix this? using System.Collections; using...
8 Mar 2022 by barbiomalefico
1. for any update you call the function Move that change the vetore move based on gravity. It start with 0 then it became different from 0. 2. Jump speed is always constant not related to the playerSpeed.
7 Mar 2022 by simple world
So i have a script that moves my player plays the animations as needed and jumps. But there are 2 problems. 1. On idle my characters speed is 0 but where i run the game the speed when i dont move the player goes 0 then 10 then 0 then 10 again,...
13 Feb 2022 by swisstackle
Im currently implementing the sweep line algorithm for line intersection in C#. Using this book: [DELETED] The algorithm starts on page 25 of the book (book page, not pdf page) I am currently trying to implement the function HandleEventPoint(p)...
31 Jan 2022 by Richard MacCutchan
private void SearchWalkPoit() { throw new NotImplementedException(); Are you sure you want to throw that exception?
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...
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...
30 Dec 2021 by Patrice T
Advice: use a CS beautifier, problem gets obvious. using System.Collections; using System.Collections.Generic; using UnityEngine; public class WeaponScript: MonoBehaviour { public GameObject Weapon; public GameObject Postion; public...
30 Dec 2021 by Satsuei-Dev
help i got an error called "CS1022" how do i fix it? it is in line 21,1 how to fix D: using System.Collections; using System.Collections.Generic; using UnityEngine; public class WeaponScript : MonoBehaviour { public GameObject Weapon; ...
30 Dec 2021 by Luc Pattyn
drop those }} in line 17 ! due to the extraneous }} the } in line 19 closes the last open { resulting in unexpected text in line 21 :)
30 Dec 2021 by Dave Kreskowiak
Nobody looks at the error numbers. The entire error message is important, including the line numbers they occur on. You have to make sure your braces are paired up. Every opening brace needs a closing brace. You should pick a single brace style...
30 Dec 2021 by 0x01AA
Have a look on line 17: 15 if (Input.GetKeyDown("f")) 16 { 17 Postion.SetActive (false);}} //
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? ...
15 Dec 2021 by matthewas
here is the book https://www.google.com.au/books/edition/Learning_C_by_Developing_Games_with_Unit/Cyj5DwAAQBAJ?hl=en&gbpv=0">Learning C# by Developing Games with Unity 2020: An enjoyable and intuitive ... - Harrison Ferrone - Google Books[
15 Dec 2021 by Richard MacCutchan
Probably not. As I suggested in your question at Can you help me code im a complete beginner[^], you need to start at the very beginning. Go to the link I gave you and start working through the tutorial. If you find it quite easy to understand...
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...
30 Sep 2021 by RickZeeland
If you want to develop a 3D game-like application, Unity 3D can be a good choice, see: languages-to-develop-mobile-games[^] Xamarin is a good platform for developing cross-platform mobile apps but might be less suitable for 3D applications, see:...
30 Sep 2021 by Member 10602079
I've only developed PC applications. This time, the company will create a new project. The purpose of making is to develop the PC application MES for mobile. First of all, it is simple monitoring and simple history inquiry. Later we will...
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...
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 >...
16 Aug 2021 by Member 15317394
It seems like a complicated and unclear question as I am not a professional in Unity and C#. I am stuck at this point for 2 months ago and I do not know if is it possible to do that or not . Briefly, I am trying to play video clips Or open the...
10 Aug 2021 by OriginalGriff
That code won't even compile on it's own. For example this line: Url _url = (uri); Which makes no sense at all, and there is nothing in that code that is named "uri" so even if the spurious brackets weren't there, we'd have no idea what...
8 Jul 2021 by HardykMahendru
Hey, I have written a wall running script but whenever I am trying to attach it to the main player, it shows this error : - Can’t Add Script - The script don't inherit a native class that can manage a script. What is it about and how can I...
8 Jul 2021 by OriginalGriff
If you don;t understand an error, the first thing to do is google it: Can’t Add Script - The script don't inherit a native class that can manage a script. - Google Search[^] 2.7 million hits on that one error message ... follow a few links, and...
31 May 2021 by HardykMahendru
Hey, I am trying to make an object that bounces back when it hit the boundaries. Here is the code that I tried running: using UnityEngine; public class NewBehaviourScript : MonoBehaviour { public Rigidbody rb; public bool isBouncing =...
31 May 2021 by F-ES Sitecore
If you want the normal angle of the contact you need something like rb.AddForce(collisionInfo.contacts[0].normal * bounce); That gets the normal angle of the first contact, if there are multiple contact points you might need to do some other...
28 May 2021 by HardykMahendru
hey, I am working on a game and trying to display the distance covered as the score. But despite the code written and debugged, the score is rising when I am moving to escape the obstacles. I want the score to increase according to the distance...
28 May 2021 by OriginalGriff
X axis, Y axis - neither will help. Try some of these: unity distance traveled - Google Search[^]
24 May 2021 by Blake Burnell
I am having a Null error that I cannot figure out how to solve, unlike my other Null errors. The error in the Unity console states "NullReferenceException: Object reference not set to an instance of an object Inventory.ClearSelectedItemWindow...
24 May 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...
12 May 2021 by Crimson Rayquaza
[code]using System.Collections; using System.Collections.Generic; using UnityEngine; public class Respawn : MonoBehaviour { [SerializeField] private Transform player; [SerializeField] private Transform enemy; [SerializeField]...
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...
9 Apr 2021 by lickmytoe /
Im using raycast to create a shooting function in my game and when i click to fire a NullReferenceException comes up, Here is my following code: void Update() { if (Input.GetButton("Fire1")) { Shoot(); ...
9 Apr 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...
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...
16 Mar 2021 by Member 15044276
I'm trying to align 2 game objects using their respective center points at runtime in Unity. The goal is to center my new generated object (SKY) to my map (terrain) which represents the center of my scene. What I already achieved is: create my...
14 Mar 2021 by Keith.Harrie
I am trying to compile an apk and I got this error com.android.tools.r8.CompilationFailedException: Compilation failed to complete, Execution failed for task ':transformClassesAndResourcesWithR8ForRelease' What I have tried: I Tried editing...
4 Mar 2021 by #realJSOP
Build a proper entity (model) in your app, and let the xml serializer handle the nasty stuff...
4 Mar 2021 by Member 15090272
Hi, I'm programming in C# for Unity. My goal is to find certain nodes in my XML file based on the attribute("ftProtect", "ftWarn","ftWarn2"), create new files and put the datasets (content) in there. For each attribute all datasets...
28 Feb 2021 by Member 15085691
using UnityEngine; public class PlayerController : MonoBehaviour { public Animator animator; void Update () { if (Input.GetKeyDown(KeyCode.J)) { animator.SetTrigger("sword in"); } } public class Identifier { } public Animator Update () { if...
28 Feb 2021 by OriginalGriff
In C# a change in the return type does not make two methods have a sufficiently different signature that you can declare two of them and the system will sort out for you which one you meant to use when you use it. To do that, you need to supply...
28 Feb 2021 by Richard MacCutchan
You have two methods called Update in the PlayerController class, plus a dummy class declaration. Judging by this and your other question you would do well to spend some time with a good C# tutorial.
27 Feb 2021 by Member 15085691
my script: using UnityEngine; public class PlayerController : MonoBehaviour { public Animator animator; void Update () { if (Input.GetKeyDown(KeyCode.J)) { animator.SetTrigger("sword in"); } } public class Identifier { } public Update () { if...
27 Feb 2021 by OriginalGriff
To add to what Dave has - correctly - said: the only time you can declare a method without a return type is when the method name is the same as the class name: when it is a constructor, and that's because the return type of a constructor can only...
27 Feb 2021 by Dave Kreskowiak
You're probably missing a void return type. public class Identifier { } public somethingMissingHere Update () { if (Input.GetKeyDown(KeyCode.k)) { animator.SetTrigger("sword out"); } }
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.
3 Feb 2021 by aitanar
using System; using UnityEngine; using UnityEngine.UI; namespace UnityStandardAssets.Utility { [RequireComponent(typeof (Text.))] public class FPSCounter : MonoBehaviour { const float fpsMeasurePeriod = 0.5f; private...
3 Feb 2021 by OriginalGriff
[RequireComponent(typeof (Text.))] Remove the dot. Dot in C# is a separator - the system is expecting you to supply a qualified type such as "Text.myclass" which doesn't exist. [RequireComponent(typeof (Text))]
1 Feb 2021 by Member 15062255
in Unity for generating a quad we need to define triangles and vertices how to define a quad in pyglet as I do in unity What I have tried: I'm just starting out in pyglet
1 Feb 2021 by Richard MacCutchan
Start by consulting the pyglet Documentation — pyglet v1.5.11[^].
12 Jan 2021 by Blake Burnell
Having a problem here while trying to create an effect for enemies to fall over after death, the Unity error says: CS1061 'Transform' does not contain a definition for 'LocalEulerAngles' and no accessible extension method 'LocalEulerAngles'...