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
7
votes
1answer
124 views

Hotkey detection for UI elements

I have several UI elements that can be opened using hotkeys for example the settings menu's key is Escape. The problem is that I have the Keycode stored in ...
3
votes
1answer
477 views

Object Pooling in Unity

I've made 2 object pooling classes - MonoObjectPooler : MonoBehaviour - can hold a single bucket of pooled objects of 1 type. ...
4
votes
1answer
2k views

Snake game in Unity

I've made a simple snake game in Unity and it has 3 different types of foods. Note - 5 blocks = 1 point This is a screenshot from the game here I'm colliding with myself and the game is restarted ...
5
votes
1answer
826 views

Simon says in Unity

I've made the Simon says game in Unity You start by guessing a pattern of 3 colors and each time you complete the pattern a new, random one, is generated and the length of the pattern is incremented ...
2
votes
1answer
325 views

Tic Tac Toe (decoupling patterns and component based design)

I'm learning Unity with C# programming and am trying to learn game design. I know the that the best way to learn games programming is to recreate some existing games, and this is my code to create Tic ...
0
votes
1answer
56 views

Disabling child scaling, when parent scales with Math

I think this code is only simple math, but I'm posting it, because almost everyone fakes the scaling with unparenting, then parenting again. ...
2
votes
2answers
1k views

High performance, branchless Intersection testing: sphere-aabb & aabb-aabb

From my tests: AABB-Sphere: 2954.8 tests per ms. AABB-AABB: 1087.0 tests per ms. The sphere test is almost 3 times faster, but the two intersection tests seem to perform about the same number ...
2
votes
0answers
110 views

Z sorting implementation for a 2D isometric game

This is a naive implementation of a Z-sorting in order to fake 3D depth using sprites in a 2D scene. I would appreciate feedback on this, especially for performance as this has to be called each frame ...
3
votes
0answers
191 views

Splines on Unity3D

I've written this small code chunk to implement a very basic spline system for object motions. As I've only used C# on Unity3D so far I would appreciate feedbacks on this, especially on access levels, ...
0
votes
2answers
331 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 ...
2
votes
1answer
98 views

Moving a player around a board, by choice and by chance

Recently I had to add 2 different sets of logic for moving my player around the board. One lets the player pick a location and move him there while the other uses a dice. I'm reusing code for both ...
1
vote
1answer
132 views

Choosing/creating/setting an NPC dialogue - follow-up

Initial post: Sequentially displaying a list of game objects This file creates a dialogue box and sets the chat history box too inactive. It finds which NPC dialogue to display, creates the list and ...
4
votes
1answer
255 views

Sequentially displaying a list of game objects

A chat background is created and text[0] is displayed with a button created under it. The created button iterates thru text[] ...
1
vote
1answer
54 views

Changing height of an UI panel using Array content

I've created following code which works just fine: ...
3
votes
1answer
97 views

Wall-runner type game

I'm working on a Wall-runner reaction based game. Whilst I know my way around a lot of the features Unity provides, I'm still in the beginner phase when it comes to working with several classes and ...
4
votes
3answers
1k views

Simple Q&A game

I just wanted to get some criticism on my programming to make me better. I made a game in Unity, just a simple question and answer game. Demo ...
1
vote
3answers
617 views

Make C# Unity Script database methods more re-usable and concise

I have a C# file, that makes some modifications on screen (changes the text on the user interface) but I have some doubts: How I can re-use the below methods to be more concise and reusable? How I ...
3
votes
1answer
129 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 ...
3
votes
2answers
3k views

RPG character, levelUp system and stat checking for object usage

So I am working on a small RPG in Unity. Right now I am writing some business classes, POCOs, that have no link to Unity except being in the required C# flavor and using Debug.Log and stuff. I have ...
0
votes
1answer
1k views

Object spawning script Unity

I'm trying to make a random object spawning script in Unity. Bellow is the code, any suggestions for improvement / changes? I'm new to both Unity and C#. ...
5
votes
2answers
473 views

Visual boardgame

The visual board game is currently a game in unity, where I've created a map and a grid. The visualization is like this: Making this code obviously needed nested for loops and the like, but ...
3
votes
0answers
223 views

Reading log file of subprocess

I run subprocesses with lot of output (compilation of Unity 3D projects). I use log parsers to find known issues. ...
4
votes
1answer
200 views

A* Algorithm speed improvement

Currently I have a very general purpose A* algorithm, which I've submitted as open sourced at https://github.com/kd7uiy/AStar . I've been trying to speed it up for the last month or so, and while I'm ...
2
votes
0answers
6k views

Blocking TCP Client with Threads vs. Non-Blocking TCP Client with Unitys Update

I'm not sure if this is the right subsite of stackexchange because it's not only about code review but a bit about design eihter. I'm currently developing a network application. I need to connect a (...
3
votes
1answer
403 views

AudioController class for managing audio in Unity games

I'm looking for a critique of this audio management system I wrote for Unity games. It references a JSON file to trigger the clips by events. The main AudioController.cs class is pasted below. The ...
1
vote
1answer
58 views

Unity3d class that inherits from button and add OnHold Event

I made my own class that inherits from button and has an OnHold event. It seems to work ok but I'm wondering if I can improve it or if you can spot any glaring ...
2
votes
1answer
911 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 ...
0
votes
2answers
10k 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
3answers
289 views

Custom struct design: Range

I had a need for some inventory management in a recent project. I decided to create a custom struct for managing the concept of a number range. It allows for easy navigation of a collection. It ...
4
votes
2answers
899 views

Voxel Islands - Dynamic mesh generation

While I can often understand the performance reasons behind using fixed-size arrays to store vertex, triangle and UV data, I've often found it annoying because it makes dynamically generating meshes ...
2
votes
1answer
69 views

Updating the player statistics text

I'm developing a game in Unity 5.3.5, I have a player statistics system with 10 different stats, as in probably every game the user is able to see the points put in each stats and also the benefit ...
3
votes
1answer
498 views

Voxel Islands - Level terrain generation

In Voxel Islands, each individual voxel is represented by their own unique class. Each of those unique classes is a subclass of a parent, Voxel class: ...
4
votes
2answers
2k views

Spell and cooldown system for an Unity game

So I have doubts about my code and if it is any good. I have a parent class Spell: ...
3
votes
1answer
64 views

Player projectile shooting

I am wondering if my code is needlessly redundant. I noticed, when looking over my code, that I had a unnecessary variable and if statement. Both ...
4
votes
1answer
160 views

How to separate data from logic when serializing types - grid tile map example

I am creating a tile based game in Unity and ran into a problem with my architecture of the Map and Tile types. The tile class contains logic like events when the tile type changes. When I tried to ...
2
votes
1answer
165 views

Range class to represent limited values, like HP, Stamina and so on

I made a small script for Unity3D, meant to be use as GameComponent for GameObjects. It is supposed to represent values that have a max value, and an actual value. In games that would be the case, for ...
3
votes
2answers
188 views

Obstacle-spawning and movement scripts

I have these scripts I made that work absolutely perfectly as I need them to. Is there any improvements that can be done to these scripts and make them more efficient for Mobile Platforms? Or even ...
6
votes
4answers
3k views

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 ...
3
votes
1answer
73 views

Unity3D DirectionalSprite

I've created a simple utility class for use in my Unity2D project, which allows a Sprite to have separate sprites for when it is facing East, North, West, or South (that's the order that z-axis ...
3
votes
2answers
193 views

Changing a sprite depending on variables

I have code here which will change a sprite depending on the variables called gunUpgrade and moveUpgrade. Any way to make the code simpler or shorter? I'm using Unity 3D. ...
2
votes
1answer
138 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 ...
6
votes
2answers
1k 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 ...
4
votes
3answers
5k 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 ...
2
votes
1answer
110 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
92 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
227 views

My game manager

This is my game manager script and is there anyway i can improve this code. ...
4
votes
3answers
406 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
5k 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 big-...
6
votes
1answer
1k 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# ...
6
votes
2answers
246 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 ...