76,863 questions
Tooling
0
votes
1
replies
33
views
Teleport system in unity for vr
This is my first time using unity im trying to implement a teleport system in my vr unity game but its not working, i have a OVRCameraRigInteraction, a plane with a mesh collider, teleport ...
1
vote
1
answer
66
views
Unity C# - Using one gameobject to control other randomly picked gameobjects
This is my goal. I want to randomly assign gameobjects for other gameobjects to control, but I want for each one to be able to control more than one. Right now, the code will run through an array of ...
0
votes
2
answers
62
views
What do Unity’s two CursorModes actually do?
When trying to set the cursor in Unity by the method Cursor.SetCursor, one of the parameters we are required to pass is cursorMode, an Enum of type CursorMode. This Enum has two values, describes like ...
0
votes
1
answer
46
views
How to use 2d texture arrays with shadow maps
The documentation about shadow maps tells me to include
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
The documentation for 2d arrays
uses `...
Advice
0
votes
1
replies
77
views
how to make my character's jump feel more responsive
I'm just getting into coding in unity for the past couple month and decided to try my hand in 2D, i made this player controller and it works well but when i playtest it the jump just feels ...
1
vote
1
answer
95
views
Character randomly looks up or down in a jerky motion 90 degrees
I'm trying to improve my character's mouse movement. This is in a first person scenario, the horizontal movement seems perfect but at random times the look up/look down mechanic go haywire and act on ...
0
votes
1
answer
38
views
Delay in control and involuntary clamping of Wheels Collider
I was making a small scene for a project at the institute. I tried to implement the gears, but I couldn't. I rolled everything back as much as I could, but now the car is behaving strangely. If you ...
Advice
0
votes
2
replies
37
views
Changing secondary texture at run time
This is for a 2D game
I have a sprite which I have added multiple secondary textures to it like "_Shirt", "_Pants", "_Shoes" etc. Then I built a Shader Graph where I use ...
Advice
0
votes
2
replies
97
views
anybody here tried making a party fowl game clone using unity and mediapipe for android devices?
Has anyone here tried making a Party Fowl–style game using Unity and MediaPipe for Android devices?
I’ve already integrated MediaPipe and tested the sample scenes—they’re working fine.
My problem is ...
-2
votes
0
answers
80
views
Async Multiplayer Client Server Structure for Unity [closed]
My project is moving out of the prototype phase, and I’m trying to define a solid architecture for my game. It’s similar in concept to Backpack Battles, Super Auto Pets, or The Bazaar: players fight ...
0
votes
1
answer
66
views
How does RaycastHit2D.fraction work in relation to CircleCasts?
I'm asking because there are 2 distinct possibilities as to how RaycastHit2D.fraction works when the hit value is returned via a Physics2D.CircleCast that begins with the centre of the CircleCast ...
Best practices
1
vote
3
replies
54
views
How do I check for whether a raycast is hitting a surface normal or if it's hitting the inside of a collider?
I'm specifically using Physics2D raycasts and I want to check for this in order to prevent multiple collisions occurring around the same surface (as the raycast hit point overshoots slightly due to ...
1
vote
1
answer
61
views
Unity 3D Player movement works but Jump keybind does not
I'm new to Unity and trying to make a character that can move, jump, etc. However, the jump isn't quite working correctly. The player can move and look around perfectly fine but the jump mechanic ...
1
vote
2
answers
94
views
Automatically tie a UnityEngine.Profiling profiler sample to every method in a class
When using UnityEngine.Profiling, we can sample parts of our code in order to understand how much time and space they take up whilst running, like so:
using UnityEngine.Profiling;
public class ...
Advice
0
votes
0
replies
73
views
Magic Leap 2 - is there an equivalent to Holographic Remoting (Hololens2)?
I previously used MSFT' Holographic Remoting with Hololens 2 as I needed the resources of PC for my Unity application.
I am now developing a different application in Unity for Magic Leap 2. I was ...
0
votes
1
answer
95
views
How to mimick the compiler type cast in runtime
What I am trying to do
I need to perform implicit and explicit type casts at runtime (using Reflection) for basic types and other types that may exist in the code (known at compile time), including ...
0
votes
0
answers
60
views
WebXR + Unity build failing to render on Quest Browser after working previously
I am building a VR web app on Unity and using the WebGL platform with the WebXR export. I am not doing much special at the moment except using the WebGLTemplate HTML file to request an XR session when ...
0
votes
1
answer
118
views
Addressables doesn't unload
I'm exploring Addressables and have encountered a problem. The code shown here correctly unloads resources (the profiler shows the number of handlers is zero and the status is none):
[SerializeField] ...
0
votes
0
answers
71
views
Unity IPointerMoveHandler, IPointerClickHandler callbacks with New Input System
I'm having trouble understanding how the "IPointer" (IPointerDownHandler, IPointerMoveHandler, IPointerUpHandler, IPointerClickHandler) interfaces are supposed to work with the New Input ...
1
vote
1
answer
101
views
Unity Action decouple classes
I'm learning Unity to know how to avoid dependencies. I have these two classes, one that generates an event:
public class ClickController : MonoBehaviour
{
public static event Action<...
0
votes
0
answers
124
views
List inside dictionary repeating the same element indefinitely
Note: Someone in the first iteration of this question said that CheckForMagicPoint() is being called every frame, but it is not, as checkingForMagicPoints is only set to true when someone is using the ...
Best practices
1
vote
2
replies
136
views
Naming Conventions: Manager, System. Handler or Service?
I have a bunch of background systems that do various things.
I.e:
UnitManager : holds all the information regarding all the player units in the game
SaveSystem: self-explanatory
UnitActionSystem: ...
0
votes
1
answer
100
views
Unity animation and sound effects out of sync
I'm trying to create a First Person Shooter (FPS) game on Unity.
I'm currently facing animation + sound effect (sfx) problems as they are not getting synced.
The shooting sound effect is getting ...
0
votes
1
answer
107
views
Unity crashes after I run my save file script
I'm trying to create a save file that save the position and speed of all objects in the scene, however when OnSave() is called, the unity editor completely freezes and doesn't seem to do anything.
...
2
votes
2
answers
83
views
Unity NGO NetworkList of struct that contains an array of struct
So I have a simple struct that contains just a FixedString32Bytes and an int like so :
[System.Serializable]
public struct SimpleDataStruct : INetworkSerializable, IEquatable<SimpleDataStruct>
{
...
0
votes
0
answers
39
views
Unity IAP 5.1.2 and StoreController Fetchproducts question
I am currently using Unity IAP version 5.1.2 to retrieve the product list from the Google Play Store. The code is written like this, but the problem is that there is no response at all—neither success ...
Advice
0
votes
3
replies
100
views
How can i rotate my player according to mouse position?
I have 3d scene but 2.5d view i have to rotate player according to mouse position and i want to move player according to wasd keys.I am using the new input system. I also want to make animations if ...
Advice
2
votes
2
replies
98
views
Best way to make a camera controller in Unity (New input system)
I am using the new input system, trying to make a decent camera controller. My current code is:
private void RotateCam()
{
Vector2 look = InputManager.look; //lookAction.ReadValue<Vector2>();...
0
votes
0
answers
65
views
Confusing behaviour of 'hover' state for Unity UI Toolkit Buttons
I have the following setup:
btn.uxml:
<ui:UXML xmlns:ui="UnityEngine.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd"
editor-extension-...
Advice
0
votes
0
replies
74
views
How can I use NearbyConnections (as provided by Google Play Services) in conjunction with Unity to send data between players?
I've been running myself ragged trying to figure this out, since the documentation is rather sparse and the plugins are all somewhat out of date, but for a school project, I need to create a prototype ...
0
votes
2
answers
104
views
How to make a list of objects visible in Unity Inspector?
I'm trying to create sort of a weapons database for a game in C#.
I have already defined the properties that each weapon should have, so it's easy to keep adding weapons.
But I'm having a hard time ...
Advice
1
vote
5
replies
92
views
How to compare 3d directions as equidistant on both diagonal and horizontal/vertical
I'm currently using Unity (and C#) in a direction comparison system I'm currently making. For a cut down example, these are some directions I have:
{Up, {0,1,0}}, {UpRight, {1,1,0}}, {UpRightForward, {...
0
votes
0
answers
50
views
Unity Android: AudioSource.Play() works in Editor but no sound until first screen tap on device
I am building a "Virtual Human Front Desk" app in Unity 2022.3 (C#) for Android.
The app flow:
Download TTS audio (WAV or MP3) from a remote API
Convert it to an AudioClip
Play it using ...
1
vote
1
answer
121
views
Why is my Object not updating its relevant position to myHands?
I'm using a PickUpObject script where you pick up objects.
I've realised that the object, when held, does not follow relatively to myHands. Also, you can throw the object indefinitely.
For more ...
Best practices
0
votes
3
replies
67
views
Best practice for separating level meshes in Unity/Blender (ceiling and main map)?
I recently created a 3D map for my Unity game. The level is a cave, so I’m not using a skybox — the ceiling is part of the 3D model itself.
For convenience, I divided the map into two separate objects:...
0
votes
0
answers
63
views
Unity: ML-Agents training freeze with RenderTexture on Unity 6.3 LTS and ML-Agents 4.0.2 (eventually resumes)
I am training a PPO agent using ML-Agents 4.0.2 on Unity 6.3 LTS and I am encountering a reproducible long-running stall that appears to be related to visual observations via RenderTexture.
The setup ...
Advice
0
votes
4
replies
56
views
Confusion on TextureHandle disposal in URP Render Graph
I was reading the TextureHandle documentation and noticed it mentions that we don’t need to manually dispose of a TextureHandle, since its lifetime is managed automatically by the Render Graph system.
...
0
votes
0
answers
46
views
Unity UI drag: OnEndDrag sometimes not fired with multi-touch, causing IsDragging to stay true
I'm implementing card drag in Unity UI using IBeginDragHandler, IDragHandler, and IEndDragHandler.
I found an intermittent issue on mobile when users touch with multiple fingers during a drag (even ...
Best practices
0
votes
0
replies
35
views
Can Unity Netcode for GameObject be used for streaming video?
I'm using Unity Netcode for GameObject into a videogame project and now the requirements have changed. We also need to stream video in a N to N architecture (max 4 players).
Can NGO be used for this ...
1
vote
1
answer
61
views
Using FixedUpdateNetwork In Shared Mode In Photon Fusion 2
I was wondering why my FixedUpdateNetwork method is not been called from my clients. It's called only from my host/master client.
The fusion doc doesnt explicitly says that FixedUpdateNetwork can't be ...
0
votes
0
answers
63
views
Android device not in the list on the Attach to Unity button in Visual Studio 2026
I am trying to debug a Unity game on an Android device by following the instructions here.
When I click either Patch And Run or Build And Run on the Build Profiles screen in Unity, the game launches ...
1
vote
3
answers
153
views
Run code in a MonoBehaviour whenever another component is added
In Unity, MonoBehaviours have various method which run automatically when something happens to them/the GameObject they are attached to - e.g. OnDestroy(), OnEnable(), OnValidate() .
I wonder if there ...
Advice
2
votes
2
replies
77
views
How to shift two intersecting polygons
I'm working on a game with procedural generation for generating dungeons.
In a dungeon I have rooms and to put it simply, rooms are basically randomly generated polygons.
After the first room is ...
1
vote
0
answers
32
views
AR Foundation works in direct Unity build but fails after exporting to Android Studio (Gradle)
I’m having an issue with AR Foundation after exporting a Unity AR project as a Gradle project and running it from Android Studio.
Working case
Build & Run directly from Unity
Plane detection, ...
0
votes
2
answers
48
views
Unity Addressables for Android: Missing Textures with scene
Don't know if anyone has run into this problem before. I'm making a Unity game that uses addressables for patching new content into the game after an executable is released.
My addressables work for ...
-1
votes
2
answers
86
views
Why is my EventSystem.currentSelectedGameObject not changing the target when I trigger with UnityEngine.UI.Button?
Here's my 3 snippets of code that I think have a problem.
SelectedManager (used to find another selectable when currentSelected is null):
using System.Collections;
using System.Collections.Generic;
...
0
votes
0
answers
96
views
How can I make it throw the object with arrow keys instead of assigning target
I am working on 2D top down trajectory throwing object game. I have this code below that throws the object to a predetermined target. I want to take out this line as this line determines the target: ...
1
vote
1
answer
58
views
Can I get a RuleTile to consistently rotate its texture by 90°, 180° or 270°?
In Unity, I have a RuleTile with a texture which is not rotationally symmetrical:
I want to make 3 other, similar tiles, where the texture is rotated 90°, 180° or 270°.
I could do that by making 3 ...
1
vote
1
answer
56
views
Procedural animation using PID regulators is framerate dependent and jittery
This is going to be long.
Context
I am developing a first person shooter. For my weapon animations, I use PID controllers to implement procedurally animated weapon sway. My goal is to make the weapon ...
0
votes
0
answers
57
views
Android Foreground Service keeps restarting when Unity app is closed
I have a Unity Android app that integrates a native Android framework/plugin I built.
I start a foreground service from the native side. The problem is: after the user closes the app (or reopens it), ...