C# is a multiparadigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

learn more… | top users | synonyms

0
votes
1answer
20 views

Resources.Load doesn't grab values of my child class

I have a parent class Unit, and child classes melee unit/ranged unit. The parent class holds uninitialized fields such as health, damage, etc. the child class sets the values of these fields in an ...
1
vote
1answer
64 views

Should frame update and network packet sending synchronous or asynchronous?

I am making a game server that has 60 Update-Per-Second (assume I can most of the time achieve it). In the current model, my main loop does the following tasks in sequence: Update game logic ...
4
votes
1answer
114 views

Convert large range of numbers to a smaller scale

What is a good formula to use in order to relate two different scale distances to each other? For example, I have a camera that can have a minimum size of 2 and a maximum of 10. I would like the ...
2
votes
1answer
42 views

Separate rotation transform from parent

I have a hierarchy like this Body - Head - Arms Currently this works fine in that the Body's transformation is reacting as it should. Being children, the Head and Arms match the Body's ...
0
votes
0answers
19 views

AttachThreadInput and PeekMessage Threading

I have a problem with AttachThreadInput and PeekMessage from User32.dll while multithreading. PeekMessage is not returning true in any case. I am designing a Windows Form that uses OpenGL rendering ...
0
votes
1answer
37 views

Unity gravity not effecting everyone like it should

so My problem is a bit weird. I have a model that will not fall at the correct speed. She falls incredibly slowly. This is the only script attached to her, and I did the "Scale to large" test by ...
1
vote
2answers
74 views

Malformed/Pixelated Vertex Normals

I am trying to generate vertex normals for a given triangles/vertices list with the following code: **BASE METHOD:** private void CalculateNormals() { for (Int32 i = 0; i < m_Meshes.Count; ...
-4
votes
1answer
56 views

Unity How do you rotate an object with a rigidbody so it's facing the it is traveling [duplicate]

I would like to know how i can rotate an object with an rigidbody so it's facing the way it's traveling.
-1
votes
2answers
82 views

2D C# Collecting Item For Acceleration Unity

I have an issue regarding acceleration for Unity in C#, I'm trying to have my player collect an item and gain speed from it. Now, I have this working, but I need it to be a gradual acceleration, I ...
4
votes
3answers
142 views

Single Switch Script vs Multiple Scripts

Would it be better to have one script that switches or have multiple scripts with each with their own function? In example, Lets say I am making a powerup script. Option 1: Create a single powerup ...
1
vote
1answer
34 views

Unable to achieve two finger panning

I'm looking to achieve a two finger smooth pan system in my project. However, the code below does not work, any interaction with the screen doesn't change to position of the camera. I am unsure where ...
2
votes
1answer
50 views

Custom Editor for Map/Dictionary in Unity

I'm trying to build my own little ResourceManager in Unity that will allow me to tag resources (ranging from materials to prefabs) to a label in the editor, and then access them in game. The ...
1
vote
0answers
55 views

AABB collision resolution issues

I'm trying to make a character collide with some tiled terrain. I have an issue with the collision resolution, and after days of shooting in the dark ant not finding any relevant help online, I'm no ...
2
votes
2answers
148 views

C# 2D Enemy Follow Y Axis Only While Rotating to Look At Player (Unity)

I have a 2D game where the player can move up and down on the y axis, I need the enemy to rotate to look at my player (which I have working, but probably isn't the best method) while also moving up ...
-2
votes
0answers
21 views

Clamping camera and smooth pan back to target.transform?

I'm looking to have a camera move horizontally, but clamped on the other two axis. Also, I would like, during the horizontal panning, for the camera to have a short delay before smoothly fixating back ...
1
vote
1answer
144 views

Kart Racing Attack AI

I am developing a kart racing game. In it, the players fight with each other while racing. There were several ways I tried to add attack AI to the enemies and the player. When the user clicks on ...
3
votes
2answers
46 views

Managing cross-platform targets/compatibility with Monogame

I recently started using Monogame for the first time because of it's cross platform compatibilities and heavily active development. The first thing I did is installing the whole framework using their ...
0
votes
2answers
64 views

entity component - get object from entity system without knowing it's ID

Ive been building a game using a Entity Component system, but im having a bit of an issue finding a specific object in my entity system without knowing the Entity's Id. My game is organized in ...
0
votes
3answers
83 views

player moving continuously from button controls

I added new buttons in my game made with unity 5.0 and the new UI feature. The player keeps on moving when button is clicked instead of moving just once. In the normal controls I make it move only ...
3
votes
2answers
81 views

How do I integrate drag over distance?

In my game I want to model kind-of-accurate bullet physics. I have the following drag equation (in C#): float drag = 0.235f * density * velocity*velocity * Mathf.PI * sizeMM*sizeMM/4000000; In ...
0
votes
3answers
93 views

Health bar - calculating health bar's position from percentage

I'm making a simple health bar in Unity 3D. Health bar UI is made from images. I'm having a problem with setting bar's position based on health percentage. Here's a script part: percentHealth = ...
0
votes
2answers
27 views

Getting unit to complete rotation before moving?

I've been trying to get a unit in my project to move in a fashion similiar to that of modern MOBA games. However, I am faced with the issue of the unit moving before the rotation is completed and the ...
0
votes
1answer
39 views

What is the difference between a game object being disabled and it made inactive?

I am looking over a script that has a particular function called to disable the script and mark a list for re-structuring: void Disable() { gameObject.SetActive(false); isEnumerated = false; ...
0
votes
1answer
17 views

Unable to get object to rotate to looked position?

I'm trying to get an object to smoothly rotate towards a clicked point in my terrain. However, my code only yields jittery movements in the other direction. Any help will be greatly appreciated. ...
0
votes
0answers
41 views

I have a script that changes an object to a broken version of itself when clicked, but it keeps rotating the object

So I have made a script in unity that you put on an object and when you click the object it will delete the object and replace it with a broken one I made in blender. My problem is that when I click ...
0
votes
0answers
28 views

Mesh tilemap and scrolling

I'm working on a top-down game where the player can move up, down, left, or right. I've come across tilemaps but since using Unity, I'm seeing the idea of using Meshes. I don't quite understand how ...
1
vote
1answer
54 views

How can I mask this CanvasRenderer?

I'm creating a text box that allows for selectable text, based off of Unity's InputField. An issue I am now facing is that the selection highlight does not respond to masks (The parent has a mask, but ...
0
votes
1answer
22 views

Getting curved-based zooming speed?

I am able to get a fairly smooth zooming function going on in my project. However I'm hoping to achieve a non-linear function. I've tried using the smoothstep function but it doesn't feel smooth ...
1
vote
1answer
26 views

Update total enemy counter after single enemy is defeated?

So I have a list that counts how many enemies are in the area. But when I kill an enemy, the list shows that that element in that array is missing, and doesn't reduce the enemy counter. How can I get ...
2
votes
1answer
74 views

How do I make an AI that stays at a distance from the player act correctly when cornered?

I am working on a few different AIs for a tile-based game. I'm trying to figure out one where that tries to keep a certain distance from the player. So if distance becomes small, move away. The whole ...
0
votes
1answer
37 views

Enemy AI with Rigidbody - Floating in the air

I'm working on my enemy AI scripts and I'm using a rigidbody to have the enemies chase the player when the player gets into its aggro distance. Two of the main problems I'm having: When the game ...
0
votes
2answers
56 views

How do I trigger OnSelect() via the ISelectHandler in my class?

I'm trying to figure out how I can make a custom UI element identify when it has been selected or deselected. Classes such as Selectable inherit from the ISelectHandler and IDeselectHandler and their ...
0
votes
1answer
65 views

[Unity]Making sure playermodel only moves 1 unit

I am doing a school assignment based off of the Unity3D tutorial 2D RogueLike (all code available here) In my version though, the movement is not turnbased and I am having some trouble figuring it ...
-4
votes
0answers
26 views

How can I add a force to a gameObject when I touch UI button in unity 5 [duplicate]

I'm using unity 5 How can I add a force to a gameObject when I touch UI button I want the ball to jump when I press that UI button
2
votes
2answers
93 views

2D Simplex Smooth Cave Generation

So I'm creating a system of caves below my random terrain generation, and I'm using 2D Simplex Noise to do so and I have a pretty good grasp on generating the random caves. However, the cutoff from ...
-5
votes
0answers
41 views

First game job in UK. Engineering school but not experience in the field [duplicate]

I am about to relocate in UK, in any town. I would really like to work for a gaming company. However, almost all big studios have as a requirement to have similar work experience in an AAA title. Or ...
0
votes
1answer
43 views

Getting position of finger along a screen

I'm trying to get a list of Vector2 position by tracking my finger and then tracing them with a prefab (Basically just gestures). I have appended an onGUI function to help print out the list of ...
1
vote
1answer
60 views

1D Simplex Noise Returns Same Generation

I've been using 1D Simplex Noise to create a random world surface, and it keeps generating with the same looking surface terrain, with some minor variations. Here is my sample code- Tile[][] tiles = ...
3
votes
1answer
130 views

Fade between scenes

So I have googled how to do this already but all the answers were for older versions of unity and use things that are not applicable anymore. I am trying to do is fade the screen to white when the ...
0
votes
0answers
30 views

Unity Input manager with chain of responsibility and delegates

I am working with unity and I am trying to build a better input system for my game. In essence there would be a singleton class that is the input manager. The player would subscribe to the manager ...
0
votes
1answer
37 views

How can I get complete path of a sprite?

I want to get a path of sprite using the spriteRenderer component in Unity.I want my path should be like - "asset/PATH OF MY FILE/FILENAME.EXTENSION". Currently I am using following code but it ...
2
votes
1answer
88 views

What is a reasonable way to avoid GC issues in Unity?

I've been reading about how garbage collection is a big problem when programming games using C#, Java, and the like - if you have a large amount of objects, the GC will run sporadically and scan ...
0
votes
3answers
86 views

How to change the gravity with a click

How to change the gravity of a ball upward with a click Then change it again downward with another click And so on In unity
0
votes
1answer
30 views

Unity3D - Change player input axes on trigger

Hope someone can help me with this, it seems like it should be a simple problem but that only makes it more frustrating! I have a simple game where you roll a ball around by applying force to the ...
0
votes
0answers
34 views

Is resource management a good idea when dealing with animations?

New to the Unity environment here and I have a question concerning how to efficiently manage computer resources in a top down 2D game. I have a large area that looks like a 2d rpg from the 90's and ...
0
votes
1answer
39 views

Rotation with respect to world instead of the object itself using Quaternion.Euler in unity

[Other answers on similar questions on stackexchange didnt help] This script is giving some weird outputs On running this script If I press rightarrow once followed by 's' the object rotates on 'z' ...
2
votes
1answer
112 views

Blur effect on background to make the forground more clear unity

I'm making a game in unity and I'm trying to add a background blur effect to my game to make things a bit more clear. Here is an example of what I am looking to do: I'm trying to get the background ...
0
votes
0answers
63 views

How can I detect collision between two objects

I have some code that when I click on an object with my mouse it will change it to another object. I'm using this code to change an object into a shattered version I made of it for destruction ...
2
votes
1answer
86 views

How can I get the user altitude from an iPhone using Unity 3D?

I can see in the Unity 3D documentation that its possible to get the altitude of the user from their iPhone, but I cannot figure out how to actually do it. I try this code: using UnityEngine; using ...
0
votes
2answers
164 views

Rotate an object smoothly by 90 degrees on key press in unity3D

[I saw few similar question on stackexchange but none is solving the purpose.] I want to rotate a 3D object by 90 degrees on different axis on respective inputs. For example if 'a' is pressed, the ...