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
1
vote
2answers
62 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 ...
1
vote
0answers
18 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 ...
0
votes
1answer
44 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 ...
0
votes
1answer
44 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 ...
2
votes
1answer
78 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 ...
1
vote
0answers
47 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 ...
1
vote
0answers
57 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: ...
2
votes
1answer
152 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 ...
2
votes
1answer
62 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 ...
2
votes
2answers
55 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 ...
5
votes
1answer
109 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 ...
4
votes
2answers
66 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 ...
3
votes
1answer
61 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 ...
1
vote
1answer
32 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 ...
1
vote
0answers
22 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 ...
0
votes
0answers
29 views

Make touch drag more intuitive/smooth for AR-Application in C#

I am currently working on an app to augment pictures on a vertical plane. Once the vertical plane is placed, the user is able to put an object on the plane. The placed object can be selected and ...
2
votes
1answer
50 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 ...
1
vote
1answer
72 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 ...
1
vote
1answer
49 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 ...
2
votes
2answers
75 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 ...
1
vote
0answers
43 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, ...
2
votes
1answer
51 views

detecting isolated voxel-blob in 3D cube with breadth first search

I just recently got into c# and Unity coding, and would like to put this algorithm and code up for review to check how I'm doing. I've only been working by myself, so it would be interesting to hear ...
6
votes
3answers
371 views

C# Event Manager without allocations

I'm using my own Action-based Event Manager for a while and looking for ways to improve it. Mainly it's used in game development, where excessive garbage generation can lead to severe consequences. ...
7
votes
2answers
288 views

Strongly typed unit system in C#

I am working on a Units library for a personal project that is a physics-heavy C#/Unity3D game, and I am looking to improve it in a few areas: Is there a way to reduce the code duplication? Is ...
2
votes
0answers
108 views

Unity rotator script

I was playing around with Unity's new Entity Component System and I was trying to implement a rotator system. This is what I came up with: Component Data: ...
3
votes
0answers
36 views

Accurate && precise location data within a timeframe (session)?

Scenario A session would start & end within a time frame. Within this time frame, the device would be moving within a constraint environment. The movement would be extremely slow (slow-walking to ...
3
votes
1answer
114 views

Generic object pooler implementation for Unity prefabs

2 scripts: - ObjectPooler - PoolableObject The ObjectPooler acts as a singleton manager of poolable objects. Any prefab can be instantiated using the pooler via: ...
3
votes
1answer
8k views

Generate Unique ID in C#

Objective To create a unique id with few characters as possible. Language: C# Engine Unity3D Target : iOS && iPadOS Scenario I found quite a few solutions from Stack Exchange but would ...
3
votes
0answers
47 views

Manage independent script component architecture in unity

I have different set of objects where I have to show Name UI and Menu UI using OnMouseDown and on OnMouseEnter Events. Remember ...
7
votes
3answers
547 views

Averaging quaternions

To compensate for shaky hands when holding a mobile device I'm averaging the rotation of the phone over the last n (in this case 16) frames, and setting the camera'...
7
votes
2answers
151 views

Finding a way to make this 2D loop faster?

So I'm creating a unity3D game with infinite terrain and it's going great! However, I'm struggling with a specific but important part of the 'infinite' terrain. Make the terrain actually infinite. I ...
4
votes
0answers
42 views

Imrpove code for loading components [closed]

It is a usual pattern when creating a new component, to load references to other components of the same GameObject. Here is an extreme case: ...
2
votes
0answers
125 views

Access a variable after several references

I have a team lead that used to write references in a single script then access it in every script. Like for accessing a variable he has to write code in this way ...
3
votes
0answers
43 views

Procedural Generation

I'm currently working on a procedural generated terrain. I've written the Chunk script, and it works great. When I generate a few chunks in Unity, it runs alright, but it could definitely run better!...
4
votes
2answers
479 views

Optimizing Infinite terrain in Unity

I wrote a infinite terrain script which works! Saddly everytime the player moves a chunk it lags for a moment. I know my code isn't great but I'm here to learn why and get this working too :D <...
10
votes
2answers
1k views

Bouncing map back into its bounds, after user dragged it out

Users like exploring maps, seeing all that is around. However they tend to go too far. To prevent the map from getting lost to the user it bounces back into the set bounds, as defined by a rectangle. ...
2
votes
2answers
166 views

Quaternion and Vector3 transfomation Math

hi I have made and AI for my enemies which works perfectly but a particular section of code is repetitive and I feel that it can be optimised ...
3
votes
2answers
44 views

Unity Custom InputManger for Cross-Platform Input

I have been working on my game for quite a while. one of its key features is cross-platform local multiplayer for example 2 players on 1 keyboard and some people on the controller. However after ...
1
vote
1answer
72 views

Load/unload models from a specific URL based on player position [closed]

I have to load/unload models from a specific URL based on player position. For this reason I am checking player position from model and then load/unload a related piece of model in an Update event ...
7
votes
0answers
384 views

Unity3D shader for rendering 2D sprites with a pseudo-glitch effect

I'm making a puzzle game in Unity with sprite-based graphics. When the game is paused, I want to hide most game elements, because I don't want the player to be able to pause and leisurely think about ...
2
votes
0answers
392 views

Making a Icosphere in C# and Unity

In Main.cs, which is attached to a GameObject that has a MeshRenderer and MeshFilter: ...
7
votes
3answers
714 views

Rock Paper Scissors coding challenge

I did a job application to a Unity developer position and i was given a coding challenge which was implementing a Rock Paper Scissors game or a variation of it. I have implemented the game using Unity ...
7
votes
1answer
3k views

Non-blocking TCP and UDP in Unity3D Game Engine

I would like constructive criticism of a networking plugin I've written for Unity 3D. The use-case of the code is for people in "creative coding," where simple TCP and UDP messages are used for ...
5
votes
3answers
655 views

C# Unity Object Pooling (for a shooter game)

I am currently developing a Bullet Hell (shoot-em-up) game for my school project. I have implemented Object Pooling for my game to recycle mainly bullets. (Though I could use it to recycle enemies in ...
3
votes
1answer
107 views

Saving allowed positions from a 3x3 matrix

I wrote the next code chunk to save all the allowed positions from a 3x3 matrix, it's working but I think it could be better. Besides something similar happens in my Randomizer class, although I admit ...
2
votes
2answers
80 views

Class for handling player movement and / or similar behaviour

I am currently developing a Unity-based multiplatform game (PC, iOS, Android) in a small team. This is the code we have created for the character actions inside the game. I am looking for feedback on ...
2
votes
0answers
65 views

Generic DialogueBox class with different parameters

I have implemented a DialogueBox class which can be static, singleton, service locator, etc. I have written it as a singleton pattern and implemented it in Unity3d engine. It is a part of a game. I ...
5
votes
0answers
116 views

Prototype GameManager for game written in Unity

I am self taught, so I'm consistently seeking ways to code better, and more efficiently. If anyone has the time, please advise me on what can be done better with explanations as to why the old method ...
4
votes
1answer
232 views

Offline .io style game built in Unity

I am creating a .io style game through Unity and it's coming along nicely. This is my first time working with Unity, and my first time using C#; I have been a Java coder. Could you good people tell me ...
2
votes
0answers
290 views

Unity Generic Pool System

So i'm using this for pooling my gameObjects in game. Every other script can ask for a pooled GameObject using ...

1
2 3 4 5