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.

learn more… | top users | synonyms

6
votes
1answer
91 views

Do you want to be a super (voxel) hero?

I have implemented an upgrades system in my Unity3d game, and I am pretty sure that I am not doing things in an optimal way. Any advice regarding best practices would be much appreciated. The idea is ...
8
votes
2answers
193 views

Procedural World in Unity3D

The idea here is that rather than placing objects directly into the scene, these building objects are instantiated at run time and placed in the correct locations. This gives me full control over ...
6
votes
1answer
69 views

Generating 3D voxel terrain with Perlin Noise

I've created this simple 3D voxel terrain generator using Perlin Noise. I have a few concerns about it though. Is there any way to make it more performant? It currently takes ~1.5 seconds to ...
6
votes
2answers
139 views

Finding a gameObject on a screen

I'm working on a warning system for my game. I want to display an arrow on the screen where the object is going to be coming from. Here is an image of what I have in mind: The object will spawn ...
7
votes
1answer
108 views

Dynamic network messaging

I'm building a client and server for a game but wanted a generic messaging system in a shared library that let me focus on application logic and was largely separate form the underlying networking I/O ...
3
votes
2answers
78 views

Player Rotation script

This is my player rotation script. I just want to make sure my naming conventions are right. If there is any way to make this code more readable I'm open to suggestions. This is also my 3rd post about ...
4
votes
2answers
81 views

Calculating which direction my enemy should face when moving

I have just implemented an algorithm which calculates the direction an enemy in my game should face when moving to a location. This is a 2D game where characters can face in one of four directions: ...
14
votes
3answers
271 views

Simulating gravitational attraction between bodies

I'm currently working on a simple simulator in Unity3D that involves planets orbiting each other. I wrote the following C# script to do that. It uses the classic gravitational formula, ...
5
votes
1answer
63 views

Long Player movement script

All of this does just one thing. Move my player by finding the first finger that was used to touch the ship and drag it. I have a few questions: The first thing is I have an embedded class of ...
6
votes
1answer
222 views

Video Game AI State Change

I have here a snippet of code from a simple video game AI enemy. The basic idea behind the enemy is that he can be in one of a few states. By default he is in a patrolling state, where he moves ...
2
votes
1answer
51 views

Object pooling for a top down shooting game - Revision #1

After the advise from this code review I have come up with the following changes. I'll go in the same order as my previous post. This post is mainly for an updated version so that others can see the ...
4
votes
1answer
105 views

Object pooling for a top down shooting game

I have an Asteroids clone I'm working on and I want to see if my object pooling is written correctly. The code works I just want to know if there is anything else I need to change to make it more ...
4
votes
3answers
115 views

Generating Heighway dragons in Unity C#

I'm basically looking for a general critique. I'm just starting out and would like to know if I should have done anything differently to make it faster or to make it much more readable. I don't know ...
3
votes
1answer
51 views

Manual slide-in animation using delta time

I created a simple slide-in animation for my game. The box is shown at the bottom with character dialog. The animation is as follows: A square slides in from the left, then waits a bit, then expands ...
8
votes
2answers
127 views

Is my implementation of FizzBuzz overkill?

I am doing FizzBuzz on a take home test (in Unity). I am sure this is just a competency check, but I went ahead and followed some coding conventions such as using constant fields, dependency ...
5
votes
2answers
60 views

Method that renders all existing drawn lines on the view

I have several tabbed views with a Unity scene in them. What I do between scene is hide the elements in that scene, then render them if the right view is shown. The method below is the method that ...
5
votes
2answers
173 views

Calling a method to draw parallel lines

This question is a followup to the last one. I followed RobH's advice and his edge case bug found in my code with this solution: ...
4
votes
1answer
135 views

Number Wizard game

This is a number guesser that guesses a random number between the values that you set. The user has to use the up or down arrow keys to say if the number that they thought of between the number ...
0
votes
1answer
104 views

Helper class to interact with Unity's PlayerPrefs system

Unity3D has a class for platform-independent data storage called PlayerPrefs. Supported data types: int, ...
2
votes
1answer
53 views

Removing checks that are only necessary on first pass

I've got a function that's executed in a game loop. There are a couple of checks that are really only necessary during the first pass of the game loop. How can I remove these? There is more code like ...
5
votes
4answers
200 views

A basic rocket controller for a Unity game

I'm currently learning C# so I can make real games with Unity. This is the first C# program I've built in Unity. Essentially what is does is control the thrust, and rotation of a ...
5
votes
1answer
121 views

Multiple functions to establish a fallback value for a property until not null

I have a property (called "Head") that can be set externally. When "Head" is not set, it uses Unity3D's MonoBehaviour functions to try to find the best value for ...
3
votes
3answers
189 views

Unity simple map generation

I am trying to generate a simple map like this. Everything works as I want, but I am new to programing. Is it a good way to do something like this? And if not, could someone explain to me where and ...
3
votes
1answer
66 views

Slow update function

I've been fiddling with Unity, trying to make nice walking/running animations. So, i found the Stealth tutorial and I used pretty much the same animator as the AI, only I only use Speed and ...
4
votes
1answer
123 views

Water generating waves and reflection

For the last few days I have been working on wave generation script. As there are a lot of calculations involved I was looking for possible optimizations to improve the performance of the code. This ...
4
votes
2answers
384 views

Checking for duplicate materials

This is a follow up question of Importing different type of files into Lists. Where the original lists are acquired. In this script I am processing the obtained lists, and comparing them with each ...
4
votes
2answers
213 views

Importing different type of files into Lists

I am using a recursive directory scan to find all objects inside a Unity3D project. After that, I wish to move all these files to a sorted List. Is there a cleaner ...
2
votes
1answer
378 views

Getting Facebook app requests

I have a JSON response from the Facebook API, which contains the app requests of certain Facebook apps via FB.API('/me/apprequests') (using Graph API 2.0, Facebook ...
6
votes
2answers
1k views

Enemy patrol script using NavMeshAgent

I'm piecing together an Enemy script to attach to my characters. This is the portion that related the a game objects ability to patrol to given locations. ...
3
votes
2answers
141 views

Triggered movement script for triggered objects

I am trying to more or less perfect a movement script that activates when "triggered" by another object. Below I have the code for both the triggering object as well as the object being triggered. I ...
3
votes
1answer
126 views

Game stats storage / display

I have a simple game where you try to go as high up with rockets as possible. I currently store 2 statistics about your playthrough: Current altitude Highest altitude These statistics are stored ...
5
votes
1answer
153 views

Random interval generator for a game

I have been working on a few games which all have a need to create "events" randomly over time. The intervals need to get shorter as time goes on if the event is negative or they need to get longer ...
3
votes
1answer
116 views

Speeding up the process of obtaining data

I created this script to obtain data from graphs online, from monavisaxmldata. I were wondering if there was a way to obtain the data faster. The program which uses this data gets presented in a ...
6
votes
2answers
141 views

Rotating a character upside down and vice versa

I have a pretty straightforward task, but I find it hard to figure out how to improve it. The code is pretty straightforward, but rather bad. There are some clarifications / extra details at the ...
1
vote
1answer
99 views

Is there a beter way to check input besides a switch case?

So I am running a Switch case to check if a user has filled in all the necessary fields within a form, and if not I prompt them to do so. I was wondering if there was a better way to do this, or if a ...
10
votes
1answer
1k views

Inspector interface serializer

I've written some code that allows Unity3D's inspector to display fields that conform to an interface. Unity has some quirks about their inspector, so as a preface they are listed here: If you add a ...
3
votes
2answers
338 views

Fastest way to find and replace inside a large amount of files

Currently I am looping through dependencies of objects, and I am trying to replace GUID (unity object ID's) inside the files. Right now I am using the following code, any suggestions for improvement ...
5
votes
3answers
117 views

Determining vehicle jump landing quality

I am writing a game where a car drives and makes jumps. When a jump is landed, the player is rewarded if they land all four wheels either at the same time, or near to the same time. If they don't, ...
11
votes
5answers
3k views

Moving character in Unity3D based on accelerometer input

I am building a infinite vertical platformer for mobile platforms using Unity3D. I am using the accelerometer to move the character left and right on the screen. ...
3
votes
1answer
138 views

Pooling System: is it worth improving or not for a simple implementation?

I am using Unity3D and I made a super simply pooling system to reuse a specific object. My only concern is I am not sure if I am doing it the best possible way. If I were doing this in C++ there would ...
8
votes
1answer
718 views

Loop through JSON and create prefab in Unity3D

I am creating an app in Unity3D and it is my first time coding in C#. I use the following code to parse a JSON file hosted on my server and use the information to render prefabs within my scene: ...
4
votes
2answers
419 views

Dynamic Storing Objects from XML in RPG

I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code. If you are unfamiliar with unity3d, ignore the use of UnityEngine, the heritage ...
1
vote
1answer
669 views

Follow Up Inventory Script (RPG) in C#

I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code. If you are unfamiliar with unity3d, ignore the use of UnityEngine, the heritage ...
1
vote
2answers
4k views

Inventory Script (RPG) in C# [closed]

I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code. If you are unfamiliar with unity3d, ignore the use of UnityEngine, the heritage ...
3
votes
1answer
159 views

Creating a masonry effect with varying height rectangles

The following is used to create a masonry effect with varying height rectangles. How can I simplify and make this more elegant in Unity? ...