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

Flip Sprite using the SpriteRenderer component

I want to create a 2D topdown game with Unity. When moving the player I also want him to rotate. Most tutorials provide a solution changing the localscale of the transform component on the x axis ...
3
votes
1answer
94 views

World resource system for Adventure Game/RPG

I'm beginning the long process of developing an Adventure Game/RPG and I was hoping to get some review on a resource system I'm coming up with. How it works is, a resource is generic to every ...
0
votes
1answer
133 views

Tycoon-style Idle game

I am creating an Idle game right now (tycoon style) which has 9 trains, (8 of them needed to be purchased), and 1 is always active, no matter if you just started the game. I was trying to create a ...
5
votes
2answers
105 views

Custom data type - “Binary” Float (0-1.0)

In my current game I have the need for values ranging from 0 to 1, or from -1 to 1. The values should never exceed this threshold, so instead of constantly validating the values I made a custom data ...
6
votes
1answer
2k views

Tic-Tac-Toe AI in C# Unity

So I have a working game of Tic-Tac-Toe with an AI that plays random moves. Is anyway to maybe shorten the endturn() function so it's not so long? Also is this set up well enough to add a mode where ...
5
votes
1answer
4k views

A* Algorithm in C# for pathfinding 2D tile grid

I am very new programming and am trying to develop a small tycoon game as a hobby project in Unity. This algorithm executes beautifully but if 100+ agents are getting new paths simultaneously there is ...
2
votes
1answer
180 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 ...
6
votes
1answer
92 views

Object creation pattern for component classes

I've been grappling with Unity's architecture for the last few days, trying to work around the fact that you can't use constructors for your MonoBehaviours (and by ...
0
votes
4answers
212 views

BestHTTP asset download

I'm using the asset BestHTTP in unity and I'm downloading a few image from amazonaws to use as texture. It used to be one image, but now I have a few. I was not able to shorten it. When I'm trying ...
2
votes
0answers
567 views

Unity post/get/check www requests with success callback and error callbacks

This is a class I built to handle post/get requests to URL's, but also check for connection and provide different callbacks depending on success or failure. It is intended to work without being ...
6
votes
2answers
246 views

Multiplayer Peer-To-Peer position interpolation

I have coded this movement interpolation for Unity3d using Photon. OnPhotonSerializeView gets called at the tickrate. Any kind of criticism/improvement suggestions are welcome. I tried to make the ...
3
votes
0answers
142 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
1answer
64 views

Jumping Game for iOS and android

I made this game called Jumpol, about you trying to jump over as many obstacles and collect as many coins as possible. The coins can be used to change your ball and revive yourself so you get another ...
1
vote
2answers
109 views

Materiel position query for a war game written in Unity

I am making a tank game. I have a database on a server where I store information about Tank itself, Hulls, Turrets, and Guns. When the server gets "Hull" request it returns all needed information ...
3
votes
2answers
3k views

Slot Machine game

Below is some part of a slot machine game that I have made using unity. I always work alone and I know I poorly comment. I also feel insecure putting this on github and show it to potential employers ...
7
votes
4answers
296 views

Call a method from all GameObjects implementing a specific interface in Unity

my player has a gun with 3 bullets. If he runs out of ammo the scene should reset itself. I don't want to load the scene again, some components should reset themselves by using an interface. So my ...
5
votes
1answer
90 views

Handling float discrepancy in Unity3d

I know there are thousands of posts and questions around the topic of Float Discrepancy. And this is not really a question but a discussion for it. After sitting ...
1
vote
0answers
404 views

Unity Tilemap RandomBrush with orientation and probabilities and fixes

Unity3D.com recently released a 2-D Tilemap system. It comes with a really basic RandomBrush for painting a random tile from a list of tiles. But the tiles were not being saved between preview and ...
2
votes
1answer
409 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 ...
6
votes
2answers
160 views

Sims-style walls part 2: Flood fill

A follow up to this post. I've ported all of it to Unity, and generally cleaned it up a little, but looking over the code, the code for flood filling is messy and repetitive. Here's a visual of how it ...
5
votes
2answers
175 views

Model-to-Prefab mapper and factory

I am creating a fluent interface to build user interfaces in the Unity game engine. As a subcomponent of this library, I have a set of objects called Components (e.g. Panel, Button, etc) that I want ...
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
1k 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
168 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
176 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
60 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
104 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 ...
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
79 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
261 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
183 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
149 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
169 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
405 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
339 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
67 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
2k 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
174 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
10k 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
880 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
594 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
198 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
253 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
89 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
396 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
146 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 ...