Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [unity]

Unity is a cross-platform game creation system that focuses on easy art pipeline process. It consists of a game engine and an integrated development environment. The game engine's scripting is built on Mono.

Filter by
Sorted by
Tagged with
0 votes
1 answer
66 views

Action delegate always return null

I have two separate classes(Tree, Inventory), OnCollision I trigger the Interact function, in which there is an Invoke of an Action delegate event TreeCollected, it seems to always return null ...
user avatar
  • 11
1 vote
0 answers
32 views

(URP Shader Graph) Why can´t I connect a float into another float 'slot'? Are there different types of floats?

So, here I´m just trying to take in a Vector3 (resulting from multiplying some noise and a sample texture) and putting it as the vertex position, but for some ...
user avatar
0 votes
2 answers
102 views

How to manually Simulate Physics properly on Unity?

I'm trying to simulate physics manualy in a Unity 3D game. I've turned off Physics "Auto Simulation" in Project Settings and wrote this piece of code (it is more or less the unity doc sample)...
user avatar
  • 123
0 votes
1 answer
13 views

Characters not applying avatars correctly

I am trying to get different models to go through animation cycles in Unity. The first four models are from Mixamo. Does anyone know why my characters end up like this (lodged into the ground) when I ...
user avatar
  • 1
0 votes
0 answers
19 views

How do I make a hollow center/hole/opening for the colliders of my 3d models in unity?

So I'm trying to have specific shapes be hollow in the center so they can fall through these posts, however I can't seem to get this working, with both convex checked and unchecked. I've also tried ...
user avatar
-1 votes
1 answer
29 views

Unity - call Start in another script's class

What I have: A scene with only a cube (player), directional light and main camera. A Player script containing functionality for movement and button press A ...
user avatar
0 votes
0 answers
12 views

How to rotate a players movement axis as camera switches? (Not used to coding)

I am using unity and I have two cinemachine cameras with two seperate camera angles. For one camera angle I want the players W key to move at a 45* slant while at the other I just want it to be ...
user avatar
0 votes
0 answers
26 views

How much grass can Unity's terrain system handle performantly, and are there any optimizations?

[Unity 2021.3.0f1] I'm making an open world game, and I'm creating the open world using the Unity terrain system. My grass model is very simple, the prefab being 4 planes with a grass texture on each ...
user avatar
0 votes
0 answers
36 views

When drawing a circle around object the radius is seems to be not accurate. what could be wrong with the circle?

This script is attached to a gameobject with a linerenderer and draw a circle around the object it's attached to : ...
user avatar
0 votes
1 answer
53 views

How to simplify the code below

I want to create 9 resistor and each resistor have 4 color code. I use a single array with size 36 to create the color code as below ...
user avatar
  • 253
0 votes
0 answers
29 views

Finger (Sensor) Shaking Detection

I want to make the user be able to shake a certain object through the phone's sensor. I have drag&drop mechanics now, and I want this shake to be directly related to that mechanics. How would that ...
user avatar
0 votes
0 answers
36 views

(FSM) Detect a change on a variable on Update, and trigger certain State

So, I'm working on a FSM that ticks on every frame. The inner workings can be simplified to this: The user (me) creates the States: ...
user avatar
0 votes
1 answer
35 views

How to create IOS style rubber scrollbar in unity?

I'm looking to create a scroll bare similar to IOS scroll when you load page or something when it lets you pull all the way down but the tension gets higher like it is on spring. How would I approach ...
user avatar
  • 127
0 votes
1 answer
38 views

How do I resume the rotation where it last rotates when it got pause?

...
user avatar
0 votes
1 answer
82 views

Is there a good practice for defining names programmatically?

In my use of Unity so far, I've been defining element names programmatically with classes like this: ...
user avatar
0 votes
0 answers
23 views

Unity Photon doesn't add physics to the second connection

I am trying to make a multiplayer air hockey game in Unity, but encountered some problems. When the first user creates the room, the hockey puck is spawned along with the first player's mallet (the ...
user avatar
  • 101
2 votes
0 answers
106 views

Tilting device about one axis in any orientation using gyroscope sensor

I am developing a Unity game where I need to tilt an iOS device to steer a ship as it flies in a straight line. The steering should be consistently accurate in any orientation, e.g. if the player ...
user avatar
  • 33
0 votes
0 answers
43 views

Graphics/Mesh scale and anchor with different screen resolution

I wanted to ask if there is a recommended approach to designing graphics that adapt and anchor to the different resolutions/aspect ratios found on different mobile devices (especially considering the ...
user avatar
1 vote
1 answer
89 views

Speed up Reaction-Diffusion simulation calculations in Unity

I'm trying to use Unity Job system to speed up some calculation related to Reaction-Diffusion simulation. The calculations requires 2 matrixes, current and ...
user avatar
  • 117
0 votes
1 answer
55 views

Unity Firebase Analytics is not working

I have been working on a new project in Unity 2021.2.12, where we need to implement Google Analytics. I have done as follows: Imported Firebase Analytics package Added the services.json file to the ...
user avatar
1 vote
0 answers
16 views

Camera not rendering to rendertexture inside class

I have an issue where I created a class to generate a lightprobe atlas texture for me, but the camera don't seem to render properly into teh rendertexture, I have no idea why... someone can help me ...
user avatar
  • 197
0 votes
1 answer
22 views

Unity 2021 Silicon Build Performs Poorly with DynamicGI.UpdateEnvironment()

I recently upgraded my large-scale RPG world project from 2019 LTS version to 2021 for the native Silicon support. I have a Silicon based Mac and even though the game seems to have smoother FPS in the ...
user avatar
1 vote
0 answers
28 views

How can I instantiate an object at a certain position?

In my game, the player drives a car and when the car reaches the end of the road, I want a different road prefab to be spawned. I have multiple road prefabs, and want to be able to spawn one when the ...
user avatar
0 votes
0 answers
43 views

How should I store the data for the puzzle pieces in my Unity puzzle game?

I am making a word puzzle game in Unity, and have a question about where to store the data for my puzzle pieces. My game uses around 60 phonemes (unique sounds). For example, the /w/ sound (as in &...
user avatar
  • 115
0 votes
1 answer
24 views

Why lookat is working but when using slerp to rotate smooth to look at the same target is not working?

This is the part when i'm trying to rotate the objectToThrow smooth slowly. ...
user avatar
-1 votes
1 answer
26 views

How to destroy just the specific powerup I hit, not all of them?

Creating a game for a computer science class - basically I have a player (cop) who will collide with donuts. When the player collides with a Donut, I want the speed to increase by 0.5 each time. Here ...
user avatar
0 votes
1 answer
46 views

How to handle multiple facial expressions in Unity 2D?

I want the character in my Unity 2D game to be able to change between many facial expressions (normal, happy, angry etc.), but I don't know the best way to do this. My character will be split into ...
user avatar
-1 votes
1 answer
32 views

Unity Update() Function causing a NullReferenceException that isn't there if I manually call the function

I have a pretty "basic" combat class here. It has a Player and an Enemy. They are inherrited from a Character class and have values such as health, armor and ar (attack rating (damage)). I ...
user avatar
0 votes
0 answers
14 views

Why does my profiler show more CPU usage after setting Application.targetFrameRate? [duplicate]

I read optimization recommendations for mobile devices on a website. It was written that "targetFrameRate" would be good to stabilize at 60 on average. I wrote the following code in ...
user avatar
  • 13
0 votes
2 answers
38 views

Unity3D UFO controls

As a fairly new Unity programmer I'm working on a small game which involves an UFO insert X-files theme Following YouTube-blogger Brackey's tutorial for 3rd person controls I've come this far, but ...
user avatar
0 votes
1 answer
27 views

How to not create a new event every time I introduce a new "boss"

I have to create a new event when I'm going to enter a new boss phase when the current boss dies. This works, but I can see this being messy when I'm going to create a new boss each time. Below is the ...
user avatar
0 votes
2 answers
48 views

Draw 2D circles/squares efficiently with Unity

I'm doing a lot of 2D simulations using Unity, and I usually instantiate a lot of squares/circles sprite. When the number of sprites reaches 1k or higher, the FPS usually reduces to 10-20, which makes ...
user avatar
  • 117
0 votes
1 answer
57 views

Move camera when dragging right and left

I am making a 2D game using Unity, and in the game you see the world from the side like in the first Super Mario games. But instead of moving the camera by walking, I want to move the camera by ...
user avatar
0 votes
0 answers
12 views

Pixelly distortion when up close to volumetric clouds

I just getting started dabbling with game development and Unity. I'm creating a flying game, and so far have a player-controlled character set up. Next I'm working on clouds. I've set up Unity's HDRP ...
user avatar
0 votes
1 answer
71 views

How to change which monitor is fullscreening a game player at runtime?

I have a Gameplayer window running Unity2020.3.32f1. I'm making an options window to fullscreen the game. I'm trying pull up the list of available monitors to fullscreen the game to. However, when I ...
user avatar
0 votes
2 answers
26 views

Changing Model's rotation to keep its left side toward the pivot as it goes in a circle

I wrote a little script for my scene that allows my ship to circle an island, and it seems to work alright. Now I am trying to get the ship model to stay broadside to a pivot point in the center of ...
user avatar
  • 137
0 votes
1 answer
83 views

Unity stops receiving input from gamepad when game is started

Update: I originally thought that it was more or less random whether the controller input works or not. I have now found out that it stops working once the game has been started for the first time. ...
user avatar
0 votes
1 answer
117 views

Unity Editor workspace buttons missing icons

In my Unity Editor, workspace buttons (top toolbar and sceneview) do not show icons Any idea how to fix this? OS: Windows 7, Unity Editor: 2021.2.18f1
user avatar
  • 1
0 votes
0 answers
16 views

Unity/Android throttles resolution to 1080p on mobile and returns Android status bar height of 0 when system running at 1440p?

I understand we can usually get the height of the Android status bar with: ...
user avatar
  • 197
0 votes
1 answer
27 views

Is there a way to not keep creating new events to spawn in my new object each time?

I have an event manager to help to communicate between two scripts. One is for the script of the object itself to pass on the message to the other one which is the spawn manager(you see below). What I'...
user avatar
0 votes
1 answer
19 views

Menu not disappearing after input

I am having some issues with the UI and the Input system. What I am trying to do is "simply" to make a menu appear and disappear upon pressing a certain key. To do so, I created an animator ...
user avatar
  • 176
1 vote
0 answers
17 views

How to tell which letter or vertex of a letter is at a certain screen position with a Unity UI Toolkit Label or TextElement?

I am using the Unity UI Toolkit and I would like to create my own TextField class (ie. input field, similar to the one I'm typing in now to write this message) with better functions using the Label ...
user avatar
  • 197
0 votes
0 answers
14 views

Why am I getting a NullReferenceException when I am referencing the object? [duplicate]

I am getting the current following error: NullReferenceException: Object reference not set to an instance of an object. This error arises with the following line of code: ...
user avatar
1 vote
1 answer
32 views

Updating chunk borders when generating new chunks

I am making an infinite voxel terrain that generates around the player. The blue boxes are the chunks that are currently loaded and the white ones are unloaded. When building the mesh for a chunk I ...
user avatar
  • 31
1 vote
1 answer
40 views

Is there a simple way to check for available space on an iOS device within a Unity app?

I was trying to use System.IO.DriveInfo.GetDrives()[0] to retrieve available disk space but that only works on a computer. I was wondering if there was any simple ...
user avatar
0 votes
0 answers
22 views

Dynamic Code Loading on Android platform

I have read a few articles on Dynamic code Loading for the Android platform Dynamic Code Loading in Android Load DEX file dynamically on Android 5.0 Custom Class ...
user avatar
1 vote
0 answers
40 views

How to modify the Unity TextMeshPro Input Field Caret?

the default caret doesn't match the style of our font at all, ideally i would replace it with an upper case "i" that uses our main Font material, is there a way to do that ? searching the ...
user avatar
0 votes
1 answer
30 views

Why do I get "the object you want to instantiate is null" when I can see the prefab reference in the Inspector?

I read the solution in this post but still not able to understand it. I have a script (AdvanceWayPoint) attached to a game object ("Cube", with tag "...
user avatar
  • 253
0 votes
1 answer
29 views

How do I fill a scene with light by using real-time lights in Unity?

This is my scene: Components of this scene: Cube Spotlight This project is under URP and I am building it for android. In this scene, I want more indirect lighting so that the objects/materials ...
user avatar
  • 1
0 votes
0 answers
13 views

Instantiated game objects go in random directions [duplicate]

I have a script that instantiates projectiles and it is supposed to shoot them in the direction of my mouse. This is my code: ...
user avatar
  • 3