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
3
votes
1answer
25 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 ...
5
votes
2answers
201 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 ...
0
votes
1answer
21 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 ...
0
votes
0answers
17 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
24 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
41 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
63 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
46 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
72 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
37 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
40 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 ...
0
votes
0answers
56 views

Unity angular gradient shader

I have created a HLSL shader in Unity to be used in combination with an image component. The angular gradient supports 2 colours, and can be masked by the source Image of the Image component. The ...
3
votes
1answer
76 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
0answers
2k views

Unity3D Property Drawer for a MinMaxSlider

This is a bit of an interesting one. Read about custom Property Drawers in the Unity Docs. Read about MinMaxSlider in the Unity Docs. Unity's ...
4
votes
1answer
494 views

Executing a sequence of actions over time in Unity

This script executes a sequence of actions over time and is based on the methods exposed by the UrhoSharp framework. I am new to Unity, but well acquainted with C# so I know what I'm doing for the ...
6
votes
3answers
209 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
146 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 ...
2
votes
0answers
79 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
34 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
0answers
45 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 ...
2
votes
1answer
3k 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 ...
2
votes
0answers
123 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 ...
7
votes
1answer
2k 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 ...
7
votes
3answers
514 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'...
4
votes
0answers
41 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: ...
3
votes
0answers
35 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!...
29
votes
4answers
5k views

Snake Game in C#

Recently, I have been trying to learn SOLID principles. I learn the best through criticism. I made this snake game in Unity with C#, where I put my current understanding of SOLID principles to test. ...
4
votes
1answer
268 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 <...
6
votes
3answers
385 views

Improving Game EventSystem

There is a Unity EventManager class from Unity tutorial that allows events to be registered, unregistered and invoked. The bad side of that ...
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. ...
3
votes
2answers
43 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 ...
3
votes
2answers
115 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 ...
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
275 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 ...
7
votes
1answer
289 views

HoloLens Unity program

I recently finished writing an HoloLens proof-of-concept program. It involves generating a user interface based on a connection with an OPC server. OPC involves industrial PLCs, one or more PLCs send ...
5
votes
3answers
501 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 ...
2
votes
0answers
151 views

Making a Icosphere in C# and Unity

In Main.cs, which is attached to a GameObject that has a MeshRenderer and MeshFilter: ...
3
votes
1answer
166 views

Endless Runner Platform Sequence

I need some help/critique on some logic I am trying to figure out. What I have feels a bit messy and I wanted to reach out and see if there is a better way to approach this. I am creating a ...
7
votes
3answers
585 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 ...
2
votes
2answers
77 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 ...
3
votes
1answer
105 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
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
110 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 ...
9
votes
2answers
877 views

Event system in Unity RPG game

I'm making event system for my RPG game, and I want to know what I can do better, because I think that there are a lot things that can be better. Note that this code is still not completed but it ...
2
votes
0answers
253 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 ...
2
votes
1answer
3k views

Controlling a drone in Unity3D

I'm currently building a game called "Drones! Attack!", and I needed a drone controller that the player can use. It's currently very simple and only supports a small amount of actions, such as: Basic ...
4
votes
1answer
206 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 ...
0
votes
1answer
68 views

Generating a QuestionID Using a Nested Loop for a Quiz Game

So I started learning OOs and code refactoring and decided to do some project. It just some simple quiz game. Here are some mechanics There are 3 sets Each set have 8 Brands (types) Each brand have ...
2
votes
0answers
52 views

Task based GameObject recorder for networked game

I've recently been dipping my toes in to async code so I'm not 100% sure if there's a better way to do this, or if I'm going to run into problems down the road. I plan on using the following class in ...
0
votes
1answer
200 views

Flip Sprite using the SpriteRenderer component

I want to create a 2D topdown game with Unity. When moving the player I also want him to rotate. Most tutorials provide a solution changing the localscale of the transform component on the x axis ...