We’re rewarding the question askers & reputations are being recalculated! Read more.

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
0answers
37 views

Touch Controls: Assigning Touches to Movable Objects within Rects

My game has a variable amount of vertically placed sectors (fields), each of which contains a cursor that moves up and down along a bar when the player touches within a given field. The sectors are ...
2
votes
3answers
143 views

4 level deep of For loops for counting objects

I'm just going to ask about this 4 Level Deep For Loop of Mine though i put it inside of the StartCoroutine(); Here is my code : please don't judge me yet ...
6
votes
2answers
908 views

Ability System Implementation

I'm making an RPG in Unity with an ability-based combat system, think Guild Wars 2 or World of Warcraft. I'm implementing abilities in an inheritance tree structure which makes creating multiple ...
1
vote
0answers
145 views

Grid based inventory

I am trying to create a grid based inventory and so far everything is going well except for one thing. The inventory consists of Grids that are built of ...
5
votes
1answer
140 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 ...
4
votes
1answer
55 views

Transferring many Vector3 across network ten times per second

I am making a game with C#/Unity, and have devised a Client-Server system to update the positions and directions of all units in play ten times a second. My biggest concern is that the more units ...
2
votes
0answers
44 views

Getting right model from list

Im not a programmer, but somehow like trying to make something, almost like a hobby. As of now i have made a list of different gameobjects (models) and i need to choose right one from that list. ...
1
vote
0answers
98 views

Getting data from a server for raffle game and saving data back to the server

So I'm making a raffle game so when you press B you get a random name with all the information of the winner. I get the data from a local SQL server and I want to make a list of the winners by saving ...
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 ...
1
vote
1answer
98 views

Compare 2 List<T> to get a List with active players

I have a little problem: I have a list with all the users that have logged in the game and a list that has all the names of the active players and I make a List with all the players as a ...
1
vote
2answers
78 views

Does checking for the Core.Instance.isLocalPlayer twice in my method constitute a bad design?

I've been writing some code for my unity project, where I am connecting players to a game and adding them to a dictionary, which is in a Database class. I have a simple method which is adding them to ...
8
votes
1answer
256 views

Game involving a squirrel and falling projectiles

I did this game as part of a game jam and I was hoping I could get some pointers on how to improve my code. I feel like the code is sloppy but have no idea of the correct way to do something. Whilst ...
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 ...
2
votes
0answers
29 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
127 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
151 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
374 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 ...
6
votes
2answers
293 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 ...
3
votes
1answer
64 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 ...
4
votes
1answer
1k 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 <...
11
votes
1answer
173 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 ...
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 ...
7
votes
1answer
798 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 ...
4
votes
1answer
474 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 ...
6
votes
2answers
195 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 ...
3
votes
1answer
242 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
352 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
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 ...
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
434 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
709 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
311 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
108 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
166 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
277 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
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
252 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
95 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
588 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 ...
4
votes
1answer
125 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
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 ...