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
-2
votes
0answers
34 views

Constructive criticism on Unity3d objectpool [closed]

I would like some review on my objectpool scripts in Unity3d/C#. Adding Objects is very easy: ...
2
votes
2answers
63 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
33 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
25 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 ...
6
votes
3answers
160 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. ...
3
votes
1answer
164 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: 1) Is there a way to reduce the code duplication? 2) Is ...
2
votes
0answers
68 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 ...
3
votes
1answer
70 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: ...
2
votes
1answer
1k 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
44 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
488 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
143 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
40 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
122 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
34 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
1answer
202 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. ...
3
votes
2answers
106 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
42 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
71 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
231 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
124 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
524 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
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 ...
5
votes
3answers
463 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
104 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
75 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
108 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
197 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
239 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 ...
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
151 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 ...
3
votes
1answer
92 views

World resource system for Adventure Game/RPG

I'm beginning the long process of developing an Adventure Game/RPG and I was hoping to get some review on a resource system I'm coming up with. How it works is, a resource is generic to every ...
1
vote
0answers
51 views

Unity Multiplayer Authoritarian Client-Server

I have created a client-server system which handles multiplayer for a game I've been making with Unity. Problem is, it feels very clunky and complex and I want to know how the design could be ...
0
votes
1answer
132 views

Tycoon-style Idle game

I am creating an Idle game right now (tycoon style) which has 9 trains, (8 of them needed to be purchased), and 1 is always active, no matter if you just started the game. I was trying to create a ...
5
votes
2answers
105 views

Custom data type - “Binary” Float (0-1.0)

In my current game I have the need for values ranging from 0 to 1, or from -1 to 1. The values should never exceed this threshold, so instead of constantly validating the values I made a custom data ...
7
votes
1answer
266 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
1answer
4k views

A* Algorithm in C# for pathfinding 2D tile grid

I am very new programming and am trying to develop a small tycoon game as a hobby project in Unity. This algorithm executes beautifully but if 100+ agents are getting new paths simultaneously there is ...
6
votes
1answer
90 views

Object creation pattern for component classes

I've been grappling with Unity's architecture for the last few days, trying to work around the fact that you can't use constructors for your MonoBehaviours (and by ...
0
votes
4answers
202 views

BestHTTP asset download

I'm using the asset BestHTTP in unity and I'm downloading a few image from amazonaws to use as texture. It used to be one image, but now I have a few. I was not able to shorten it. When I'm trying ...
4
votes
1answer
426 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 ...
7
votes
4answers
295 views

Call a method from all GameObjects implementing a specific interface in Unity

my player has a gun with 3 bullets. If he runs out of ammo the scene should reset itself. I don't want to load the scene again, some components should reset themselves by using an interface. So my ...
1
vote
0answers
346 views

Unity Tilemap RandomBrush with orientation and probabilities and fixes

Unity3D.com recently released a 2-D Tilemap system. It comes with a really basic RandomBrush for painting a random tile from a list of tiles. But the tiles were not being saved between preview and ...
6
votes
1answer
2k views

Tic-Tac-Toe AI in C# Unity

So I have a working game of Tic-Tac-Toe with an AI that plays random moves. Is anyway to maybe shorten the endturn() function so it's not so long? Also is this set up well enough to add a mode where ...
5
votes
1answer
87 views

Handling float discrepancy in Unity3d

I know there are thousands of posts and questions around the topic of Float Discrepancy. And this is not really a question but a discussion for it. After sitting ...
6
votes
2answers
153 views

Sims-style walls part 2: Flood fill

A follow up to this post. I've ported all of it to Unity, and generally cleaned it up a little, but looking over the code, the code for flood filling is messy and repetitive. Here's a visual of how it ...