Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
1
vote
2answers
182 views

Building a simple random equation of size

I'm trying to find a way to make this code more efficient than using a lot of if statements because there are a lot of combinations. The final result variable is an ...
5
votes
1answer
137 views

Code for movement controller of the player in Unity

I am writing code for games in Unity. I should write the part very often and would like to know the flaws of the piece of code. It seems like everything is fine, but nevertheless I feel that some ...
2
votes
0answers
26 views

Unit sprint mesh rendering

I have built this code in the past and I am reviewing it once again. I have a feeling that I could make the code much faster. Could someone please look at the code. What happens is that every time ...
3
votes
3answers
126 views

Get closest Entity from the Player on a 2D battlefield

I am building a little game in using Unity, and recently made an algorithm to get the closest Entity to the player on the battlefield. I made a working sample in ...
2
votes
1answer
150 views

Simple code for calculating damage increase

In my little game project, I have the following piece of code, in the static class DamageHelper, that takes a Spell, and returns ...
3
votes
1answer
62 views

Generic FPS movement controller with Xbox One controller support

I'm currently working on an FPS shooter game and I needed a generic movement controller that supported both keyboard and Xbox One controller input. My main goal in designing this controller was to ...
3
votes
1answer
371 views

Perlin Noise terrain in Unity3D

I've recently had time to devise another program so this time I decided to write the Perlin Noise algorithm in code. I have succeeded and the code works but I can't help but feel that my practices ...
7
votes
1answer
785 views

Car controlled by steering wheel

I'm a young coder who is looking to improve in my coding practices because I was told by my supervisor to look into a more healthier method to code. What I would like to ask is how can I improve my ...
6
votes
2answers
3k views

C# to C++ function call that fills and auto resize array if size is not enough

I have a C# function that calls a C++ function to fill the array with pixel data from a camera. This is better than allocating memory on the C++ side and marshaling it on C# side each time the ...
2
votes
1answer
352 views

Unity3D like component system

I am currently working on my own little game engine and thought about implementing a simplified version of Unitys component system where you can attach objects of derived ...
2
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
465 views

Testing procedure with several nested yield statements in Unity3D

I made a small game that does the following: Displays a popup with the instructions of the game Turns on the GUI Start a list of trials for the player For each trial: It shows a symbol Waits for a ...
3
votes
1answer
240 views

Mesh generation in Unity3D

I have a mesh generation script which initialises a mesh with vertices that represent my map tiles as quads. Then I pass the tiles that I wish to display on the mesh by setting my triangles for the ...
2
votes
1answer
82 views

Class to move a sprite in Unity

I first got introduced to coding with Ruby and now I am learning how to create games in C# with Unity. I am following a tutorial and I refactored the code to make it easier for me to grasp. I am ...
1
vote
1answer
350 views

Creating custom control in Unity3D that has same UI but different behavior

I made some custom control named Range Control in Unity. It has two buttons a "plus" and a "minus" and an input field that shows the current value. The control has (for now) two implementations: None-...
3
votes
2answers
145 views

Wait for multiple functions to run

In my loading scene I want to run multiple functions (IO from the disk) and start the app after they are completed. This is in my loading class. (Note: This is unity 3d and the public variables to ...
6
votes
2answers
287 views

Pulsing Alpha Channel

The following script makes an image pulse in Unity by fluctuating its alpha channel. However, I feel like there is a lot of duplicate code in the update method. How can I clean up that code to have ...
11
votes
1answer
172 views

Multiple similar manager classes for handling scroll lists

I am working on my first object-oriented programming project, written in C# for Unity. My code does what I want it to do, but I am wondering if there is a better way to do it. I think I am building ...
9
votes
2answers
725 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 ...
27
votes
4answers
4k 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
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
697 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 ...
3
votes
1answer
431 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. ...
6
votes
1answer
3k views

Sliding puzzle game of fifteen

I've made the Game of Fifteen in Unity this is how it looks : The code is rather short there's one class for the pieces and one for the game logic : MovablePiece : MonoBehaviour ...
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. ...
3
votes
0answers
112 views

Mesh Modifier System in the Unity Game Engine using C#

The system is meant to replicate the deformers and modifiers commonly used in 3D modeling programs like 3DS Max, Maya, Blender and Cinema 4D. I made a post on Reddit, explaining the features and ...
2
votes
0answers
106 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
163 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, ...
5
votes
2answers
469 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 ...
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 ...
3
votes
0answers
204 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. ...
2
votes
0answers
5k 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 (...
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#. ...
4
votes
1answer
183 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 ...
3
votes
2answers
2k 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 ...
2
votes
1answer
310 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 ...
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
3answers
258 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 ...
2
votes
1answer
68 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 ...
2
votes
1answer
96 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
124 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
251 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[] ...
4
votes
2answers
1k 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
363 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 ...
3
votes
1answer
389 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: ...
6
votes
1answer
9k views

TCP authentication server and client

This is the first time I'm dealing with C# as I'm accustomed to Java sockets, so I do want your full review and anything you think I can accomplish better or optimize in the code will be very ...
3
votes
1answer
62 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 ...
1
vote
1answer
54 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
163 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 ...
4
votes
1answer
150 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 ...