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
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
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 ...
3
votes
0answers
209 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
185 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
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 (...
3
votes
1answer
367 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
55 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
898 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
259 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
826 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
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 ...
3
votes
1answer
395 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
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
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 ...
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 ...
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 ...
3
votes
2answers
175 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
2k 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
67 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
135 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
97 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
88 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
192 views

My game manager

This is my game manager script and is there anyway i can improve this code. ...
4
votes
3answers
399 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
4k 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
234 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 ...
7
votes
3answers
1k 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 ...
8
votes
2answers
747 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 ...
9
votes
2answers
445 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 ...
8
votes
2answers
386 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 ...
8
votes
1answer
2k views

Loop through JSON and create prefab in Unity3D

I am creating an app in Unity3D and it is my first time coding in C#. I use the following code to parse a JSON file hosted on my server and use the information to render prefabs within my scene: <...
3
votes
1answer
103 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 ...
6
votes
1answer
1k 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 generate ...
11
votes
5answers
10k views

Moving character in Unity3D based on accelerometer input

I am building a infinite vertical platformer for mobile platforms using Unity3D. I am using the accelerometer to move the character left and right on the screen. ...
15
votes
3answers
1k 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, $$F=G\frac{...
7
votes
2answers
165 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 from ...
4
votes
2answers
114 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
108 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: (...
5
votes
1answer
424 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
265 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 ...
3
votes
1answer
85 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
703 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
197 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 ...
2
votes
1answer
2k 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 ...
8
votes
2answers
471 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 ...