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

2
votes
1answer
49 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: ...
2
votes
1answer
49 views

2D Unity game using 3D objects, gather points and avoid obstacles

I've been messing around with some stuff in Unity and are now working with 5 classes in my project. As I am very new to the engine, and even C#, I believe I made a rather messy code, even though it ...
5
votes
2answers
211 views

Type-Safe Event System

I have recently started writing C# from a strong JavaScript background, and found myself wanting to do something I do all the time in JavaScript: events. Since I have a type system at my disposal, I ...
1
vote
0answers
136 views

Observer Pattern with C# and Unity

I want to see if I used the Observer pattern correctly. Right now I'm using a VolumeManager.cs that implements ISubject and a ...
2
votes
1answer
56 views

Abstract factory pattern for implementing AdNetworks on multiple platforms [closed]

Here's the link to the github project. I want to implement abstract factory instead of adding platform-dependent compilation flags in just one file and make it ugly, hence decoupled code. Moreover, ...
2
votes
1answer
83 views

Unity3D script for controlling a character

This is a Unity3D script I wrote for my game to control a character. I don't consider myself a highly-skilled coder, so I come here to ask for suggestions. Is my code clean enough? How can I improve ...
4
votes
1answer
70 views

Method for obtaining adjacent chunk positions

I'm currently in the process of making a 2D tile based game. This game has an "infinite" world that can be traversed and modified as needed. I am creating the chunks with a mesh and I apply a texture ...
2
votes
1answer
62 views

Writing strings to the screen over time

The following methods just write strings to the screen over time to make it look like a typing effect, instead of all at once. The only difference is the argument in the ...
7
votes
1answer
107 views

My game manager

This is my game manager script and is there anyway i can improve this code. ...
4
votes
3answers
120 views

Facebook helper class

This is my initial Facebook helper class. Is this code efficient or is there a way to improve this code? ...
3
votes
2answers
200 views

Float to Byte Array Serialization Over Network

I wrote this code for a multiplayer game I am developing to transmit floats over the network. It works, on the systems that I have tested it with. What I am worried about is the little-endian ...
6
votes
2answers
88 views

Simulating gravitational attraction between bodies - follow up

I've decided to revisit a chunk of code I wrote a while back, and see what I could do to make some changes. As a result, I know have slow, but working piece of code which is able to simulate ...
6
votes
1answer
188 views

Unity3D native iOS plug-in to read pedometer data

I've made a plug-in for Unity3d for iOS. The plug-in's job is to get the Pedometer data from history within a specified period of time and return that to Unity for later use. I am confident in my C# ...
1
vote
2answers
60 views

Random integer range with exceptions

I have to generate a random number from a range with exceptions held in a bool array, is there a way to do it without a loop depending on probability? There is also a potential infinite loop here if ...
8
votes
2answers
170 views

Roll-a-ball controller

I've been toying around with Unity 5 lately, and in an effort to start making an actual game, I've built a ball controller similar to the one found in the Unity tutorial Roll-a-ball. In essence, the ...
7
votes
3answers
400 views

“Dice on a Yacht” game

I wrote a small program to address some assignment tasks related to making a game called 'Dice on a Yacht'. I sent the code to be reviewed by a company I was applying for, and I have not gotten the ...
6
votes
1answer
115 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
259 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
168 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
145 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 ...
8
votes
2answers
159 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
87 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
89 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: ...
15
votes
3answers
356 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
87 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
234 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
60 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
195 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
135 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
72 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
189 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
65 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
300 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
378 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
261 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
56 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 ...
6
votes
4answers
545 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
145 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
769 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
71 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
159 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
492 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
242 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
639 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
3k 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
205 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
169 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
199 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
132 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
182 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 ...