Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [unity3d]

Unity, also referred to as Unity3D, is a cross-platform game engine with a built-in IDE developed by Unity Technologies. It is a commercial development platform for creating games, interactive 3D applications, training simulations, and medical and architectural visualizations.

Filter by
Sorted by
Tagged with
0 votes
0 answers
43 views

Unity Gesture Recognition Code in C#

I'm new to C# programming and have been working on a Unity project that incorporates gesture recognition using the PDollarGestureRecognizer library and Unity XR Hands package. My application is ...
user17410204's user avatar
2 votes
2 answers
50 views

LinearUpscale2DArrayInPlace in Unity Jobs

Well, I have this function which is called in the Unity Job system, I'm profiling it: The code: ...
z3nth10n's user avatar
  • 247
0 votes
1 answer
197 views

How to optimize the player movement code like in Tomb Of The Musk game?

I've written some code that performs movement similar to the Tomb Of The Musk game. The idea is that the objet should move in a certain direction until it encounters an obstacle. After that, the ...
Hanvil's user avatar
  • 3
1 vote
2 answers
86 views

Optimize and Simplify Raycasting Code in Unity for Store Clerk Interaction?

I plan to use a raycast for interacting with all things in my games but Im afraid itll be too laggy how can I shorten this code up? ...
user22619516's user avatar
8 votes
8 answers
3k views

Can I lessen the use of boolean flag variables in this snippet?

Below snippet is part of a game application's logic and the Update function is called every frame (about 60 times a second). ...
Mukul Kumar's user avatar
0 votes
1 answer
106 views

Strategy Pattern Inside State Pattern

I'm making a fps game where I created a hierarchical state machine; the problem is the two types of movement (standing movement and crouching movement). They are very similar; the only difference is ...
Thomas's user avatar
  • 25
4 votes
1 answer
124 views

C# wrapper that binds to Rust FFI, for the purpose of running CavalierContours functions in Unity

I have attempted to write c# bindings for a Rust library. I have never worked with unmanned code / languages before. Superficially this code does work with no apparent bugs or memory leaks. I want to ...
arcadeperfect's user avatar
2 votes
1 answer
351 views

Drag-and-drop handler for card game

I'm currently writing a card-game in Unity and the below code handles the player's ability to drag/drop cards onto various sections of the game board. Right now, I have this nagging feeling that as it ...
jump's user avatar
  • 31
1 vote
1 answer
40 views

Moveable Points - Update variable without Re-referencing variable? Event Subscriptions? (C#, Unity)

So I have this helper script that I use to move points around manually while debugging: ...
FaffyWaffles's user avatar
2 votes
1 answer
132 views

Weapon shoot system FPS Game

Hello I'm currently developing a FPS game for my portfolio and I made a weapon shoot system, and I would like to receive feedback about my code to make more cleaner and efficient. Thanks. ...
Thomas's user avatar
  • 25
0 votes
1 answer
42 views

Unity. Is this a good realization of jumping mechanics?

...
Anonymous's user avatar
2 votes
1 answer
227 views

Generic Interpolation for many types in C#

I made a generic interpolator for Unity objects, but the way it functions makes me question if there's a better way to approach this problem. I want the logic inside of the ...
Thane Brimhall's user avatar
0 votes
1 answer
85 views

SceneManager class for a Unity3D game

I have a SceneManager class (code shown below) that I think should contain my "business logic" for loading scenes in some way that I want using ...
stroibot's user avatar
  • 137
2 votes
0 answers
158 views

Timer built in Unity using Async Await

For learning purposes, I built a timer that does something every x seconds in Unity using an async Task instead of a coroutine. I'd like to know if there is a less awkward way of writing this: What ...
willywinelover's user avatar
1 vote
1 answer
89 views

Code to determine move position in a hex grid when the user moves the stick on the gamepad

I have code that is responsible for determining move position in a hex grid when the user moves the stick on the gamepad. cameraAdjustedMovement is a ...
stroibot's user avatar
  • 137
1 vote
2 answers
943 views

Union Polygon Algorithm

This is my attempt at creating a Union Algorithm for an arbitrary set of any number of arbitrary simple polygons. It works for both convex and concave polygons. ...
FaffyWaffles's user avatar
1 vote
0 answers
672 views

Creating a generic base class for singletons in Unity

Singletons can be very tricky to work with in Unity, especially when you dont want to give up on Monobehaviour features. Most examples I've seen make use of ...
Jay's user avatar
  • 214
0 votes
1 answer
435 views

Moving GameObject in a square pattern (C# Unity) [closed]

I'm new to Unity/C# and I'm trying to get a 3D GameObject in a square pattern, using transform.position: ...
xabi_sides's user avatar
2 votes
0 answers
107 views

raycast interaction system

I've written a solution to make creating new interactions easier but wanted feedback to see if there is a more effective way of going about this. I've written a script called interactable which is ...
LanceRitola's user avatar
-1 votes
1 answer
81 views

Most efficient way to track a collection of targets in range of a source object [closed]

In my game there are space ships and each of these space ships tracks which other ships are in range of it. I need to perform certain logic when a target ship comes in range of another ship, and ...
wilderness26's user avatar
2 votes
1 answer
315 views

Multiplayer game byte array serializer with unity

I I'm trying to make an multiplayer game using golang and unity. Golang server side checking units on scene(like a character move). It also sends the information (position, health) of the units on ...
snn's user avatar
  • 23
1 vote
0 answers
199 views

Unity3D Observable Variables as ScriptableObjects

I'm trying to implement an observable pattern on variables, so that I can hook up UI components, etc. to change displayed values or other actions when their value changes. I wanted three features that ...
Tom's user avatar
  • 223
2 votes
0 answers
28 views

Unity player controller code

I wrote this code I am making for an open source game. I just would like some feedback to know if my code is good. One thing I have to question is my use of private functions okay? I use a lot of them ...
Zero Null's user avatar
3 votes
1 answer
532 views

Creating a Client-Side Prediction and Server Reconciliation

Preface I have been trying to find out "How to make Client-side Prediction and Server Reconciliation" from scratch with an easy-to-understand code in C#. So I decided to make my own ...
ガブリエル Gabriel's user avatar
2 votes
1 answer
110 views

Shortest route algo terribly slow

First post. I posted this on stack as well but somebody suggested I post it here too/instead. I wrote a shortest-path script for a Unity game project, and while it works, it gets so slow when applied ...
Colin's user avatar
  • 21
5 votes
0 answers
692 views

Multithreaded pathfinding in Unity C#

I've tried to implement multithreaded pathfinding in an attempt to increase performance, but if anything, performance seems to actually decrease when I enable multithreading. Is there anything I ...
xcrypt's user avatar
  • 151
11 votes
4 answers
4k views

C# - Standard 52 card deck

I made a 52 standard deck generator for practicing my C#. Just to let you know I am using the unity editor. I would your feedback as to whether my code is good/bad or whatever you may desire. ...
Mr.Banks's user avatar
  • 213
3 votes
0 answers
851 views

C# Procedural Mesh Generation Optimization

I'm making a terrain-deformation system in Unity that utilizes the common marching-cubes algorithm. So far I've gotten the system working, employed Unity's job system and burst compiler, and managed ...
Seth McCann's user avatar
2 votes
0 answers
292 views

How should I go about implementing rust into the unity3d engine?

Recently, I've explored using rust as a scripting language for unity. My current method involves creating a DLL from rust, and loading it into my game at runtime. It requires that the user use a ...
Dimitri Bobkov's user avatar
3 votes
1 answer
176 views

Remove redundancies in similar properties [closed]

I have a lot of redundancy here, but I am not sure how could I make it look shorter. ...
Enrique Moreno Tent's user avatar
2 votes
2 answers
526 views

Spawning random small cubes in a big invisible cube using Unity C#

My goal was to create a big invisible cube and inside that spawn small random cubes. These small cubes would have: A random position within the big cube. A random colour. A random size. A random ...
AaySquare's user avatar
1 vote
0 answers
205 views

Shader for 1-bit color palette + a VFX ramp

I'm making a Unity game with a "1-bit" color palette, a la Downwell - the vast majority of the screen will end up being in black and white, but unlike true 1-bit graphics, some highlights ...
crass_sandwich's user avatar
0 votes
1 answer
118 views

Unity C# - Radar works but performance is horrible (Update & LateUpdate)

Hello I need help to optimize this code. I have a radar and it gets the enemies from a list and adds an image to their location to track them. I use Update to remove the images and LateUpdate to add ...
WokerHead's user avatar
  • 159
1 vote
1 answer
403 views

Unity Static Singleton JSON Serialisation

I have a static PlayerData singleton which stores all the data for the player (gold, upgrades, heroes etc) but JsonUtility ...
Joshua Nixon's user avatar
2 votes
1 answer
150 views

Unity animations code [closed]

I'm currently working on a live keyboard demo on unity. I've animated every key but my script spans over 2000 lines. I'm fairly happy with my script but I know theres better ways to do it. I have ...
Kemura's user avatar
  • 47
1 vote
0 answers
152 views

Unity - Rail Shooter Player Ship Movement Handler

I'm currently learning C# so that I can do some projects with the language. To provide some fun learning I'm also learning the Unity engine at the same time. Currently I'm following a tutorial for ...
Turkinolith's user avatar
2 votes
0 answers
430 views

Is this a good pattern design for a Unity dispatcher for creating thread safe methods?

Well, my intention here is to allow users to execute Unity methods/properties in other threads by using this Dispatcher implementation: ...
z3nth10n's user avatar
  • 247
5 votes
1 answer
2k views

Unity surface shader to blend between adjacent tiles

I'm experimenting in Unity with a tile-based game with crisp 32x32 tile textures and pixel perfect camera. I did not like the results coming from Unity's default ...
Misza's user avatar
  • 231
2 votes
1 answer
112 views

Is my unity component validation overkill?

Unity scripts need access to components they will be using, my solution here guarantees that a script will have a valid reference to a component it needs, but is this solution overkill, or hard to ...
Jay's user avatar
  • 214
2 votes
2 answers
224 views

C# and unity. Moving an object to a target and destroy target once we're close

This is my first ever c# script. I have played around a little and I think this is some proper c# code. Since it's my very first c# ever, I'm assuming there's a few mistakes, things that could be ...
Mitchell van Zuylen's user avatar
5 votes
1 answer
215 views

A level generation script in Unity

I'm doing my first big unity project and I'm really unsure about my current code I use for my level generation. I would greatly appreciate any feedback. I'm very new to c# and I'm not at all aware of ...
ukko7v's user avatar
  • 51
4 votes
2 answers
303 views

Speed Up Flow Field Algorithm?

I am slowly creating a flow field pathfinding solution for Unity3D. I'm trying to follow Elijah Emerson's description, which appears in the book 'Game AI Pro' (volume 1). In this question I ask about ...
inappropriateCode's user avatar
3 votes
1 answer
102 views

Coordinates Struct for Flow Field Pathfinding... am I doing this right?

I am slowly creating a flow field pathfinding solution for Unity3D. I'm trying to follow Elijah Emerson's description, which appears in the book 'Game AI Pro' (volume 1). The map is divided into ...
inappropriateCode's user avatar
1 vote
1 answer
221 views

Unity Gravity script lowering FPS because of overlap sphere checking collision

What are some ideas or ways that I can increase the efficiency of this gravity script because it is way to depending for what i want it for. The game has a target at the center and there are objects ...
WokerHead's user avatar
  • 159
1 vote
0 answers
33 views

Callee specifying more spectific behaviour of the caller

I am working on a game in Unity/C#. I have a section of code that both feels like the best solution and code smell. There are two objects. A player, and something interactable. The interactable object ...
vankessel's user avatar
2 votes
1 answer
59 views

Basic Beginner Unity Project with a bouncing corona

At first I wasn't really proud of this one, but then I decided that I need to know what's so bad about it? Why does it feel unsatisfying? How can I do it better? So yeah here's a unity project that ...
Epsilon's user avatar
  • 153
1 vote
1 answer
120 views

My simple implementation of a DI container

I decided to make my own light DI container. I know about Zenject, etc. I wanted a very light analog. I'm concerned about a few things: 1) is it correct to use struct instead of class for reference ...
Mim's user avatar
  • 11
1 vote
1 answer
69 views

Optimising multiple string splits and concatenations

I'm writing a program in Unity and am using a TextMeshProUGUI object (named history) to hold a list of messages to act as a ...
user avatar
2 votes
2 answers
586 views

Storing and calculating extremely large/small numbers in C# using a Scientific Notation struct

I've been working on an incremental game that I will need to store extremely large scientific numbers. as a part of this game, precision is only important for numbers within similar magnitudes. If a ...
Erik Overflow's user avatar
1 vote
0 answers
66 views

Simple Unity program for a research experiment

I'm developing a small C# Unity application to display stereoscopic images as part of a wider research study. Since the experiment consists of unique stages (Start, during a trial, between trials, ...
Richard Robinson's user avatar

1
2 3 4 5