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
56 views

Unity C# new Vector3 problem

I get an error every time I try making a line with "new Vector3". Example 1: private Vector3 playerPos = new Vector3 (0, .5, 0); gives the error: The best overload method match for ...
1
vote
3answers
100 views

Story game loop [closed]

I have been playing story based games such as lifeline or choice of games. I was wondering what game loop best describes what's happening logically? As when mauling over it myself in my head I am ...
1
vote
1answer
39 views

Double Jump causing problems?

Here is my code. I have an empty Gameobject directly underneath the child with a small radius checking the ground every thing seems to be correctly covered, but for some reason the jumping mechanic is ...
2
votes
1answer
74 views

Problem with Rotation - C#/XNA

I have a projecile(Hook) and the tail of the projectile(yellow balls) TailProjectile class draws a ball at the exact position of the projectile(hook) and let it there until the projectile ends I'd ...
2
votes
2answers
71 views

Unity2D: Rendering multiple sprites as a single one

I'm creating NPCs in Unity 2D using C#, and I have 16x16 sprites for body, helmet, clothes and weapon. All these have a tile set which has been split in unity. I'd like to be able to render one of ...
0
votes
2answers
82 views

WaitforSeconds() not working as it should

I searched for using WaitforSeconds and used as it was mentioned(using a return type of IEnumeration and using coroutines instead of update). but it did not work. Initially it showed Waitfor Seconds ...
0
votes
0answers
55 views

Using an object as a model to avoid too many parameters - XNA/C#

I have 3 classes(Skill,Projectile and Status),Skill has Projectile and Projectile has Status, all of them need to read information from a txt and to avoid open it everytime I want to create an object ...
0
votes
1answer
72 views

Is it possible to load asset bundle dependencies manually in Unity 5.0?

Is it possible to tell Unity to not load asset bundle dependencies automatically so they can be loaded manually. If so, how can this be done?
1
vote
1answer
103 views

Keyboard.GetState() only work first time, and Memory increase (not Disposing) [closed]

EDIT UPDATE 3 I been searching the web for a solution and found several people struggling with Memoryleak using MonoGame while trying to dispose objects. It could be the case that MonoGame should be ...
2
votes
1answer
79 views

Determine if AI can traverse a given spline

I have some AI Agents that I want to navigate along a spline. The agents have a speed and a maximum turning radius. For some splines the curvature is too tight for the AI agents to navigate around and ...
2
votes
1answer
175 views

How does Unity load asset bundle dependencies and how can they be accessed?

Loading assets from an asset bundle is done explicitly. You give the bundle the name of the asset to load, then it returns it( either now or later. ) However, loading dependencies is done completely ...
0
votes
1answer
47 views

An object reference is required to access non-static member UnityEngine.Material.GetTextureOffset(string)

I am watching a tutorial where it seem to work. But in my case, I am getting this error. I get it that non-static members have to have an object. But, I don't know much about how to fix this error. ...
0
votes
1answer
62 views

Restricting my horizontal slash attack

I've been working on making this slash attack for my character in the unity engine. The whole point to this script is to put the damage range in sync with the slashing animation. The slash is ...
3
votes
2answers
52 views

XNA/C# Convert polygons into tilemap

I'm currently working on my 2D survival game, where the world is infinite and generated by perlin noise. I wanted to also include biomes and this article interested me - ...
0
votes
0answers
12 views

How to parse animation data of a .x file in SlimDX

I have a managed Direct3D9 application that uses SlimDX. I need to implement a custom animation controller. I want to parse the .x file for animation data. The SlimDX.Direct3D9.XFile and ...
0
votes
1answer
61 views

Why isn't OnTriggerExit working?

I have a price of code that looks like this: void OnTriggerExit() { Debug.Log("Object leaved trigger"); } But when I move an object that is colliding with the trigger by script it doesn't print to ...
1
vote
2answers
104 views

How to freeze rotation with a Rigidbody 2D? [closed]

So I am looking to freeze rotation in the Y axis on a Rigidbody 2D. I'm not sure how to set this in my code. This is what I have so far, can you point out my errors? public class PlayerMovement : ...
-1
votes
1answer
89 views

How to optimize my movement & collision code?

I am trying to implement movement & collision the simplest way possible. public void MovePlayer() { KeyboardState keyState = Keyboard.GetState(); Vector2 checkVec = ...
0
votes
1answer
63 views

Unity Transform.Position not returning expected position

So in my scene hierarchy, I have an object laid out like so; -Level1 --Level2 ---Level3 ----Level4 My script is attached to the Level1 object. When I try to find the transform.position of Level4 by ...
0
votes
1answer
40 views

Texture doesn't scale and repeat

I wrote the script for automatic repetition of texture background. To save it I typed Cmd+S. I dragged and dropped the script to Background in Hierarchy. When hit play button the texture doesn't scale ...
0
votes
1answer
51 views

How can I increase the speed and frequency of a spawn?

I'm using the official Unity tutorial for the Space Shooter game, and I'm at the part where the ability to spawn a set amount of hazards in a wave at a certain delay is introduced. I want to make it ...
-1
votes
1answer
52 views

Why is this unity camera moving in weird directions?

I have the following script public class CameraScript : MonoBehaviour { public bool AllowZoom; public float zoom; public float Speed; Transform board; void Start(){ ...
2
votes
0answers
69 views

Creating Scenes Programmatically From A Deployed Build in Unity

This is somewhat of an extension to this question: http://answers.unity3d.com/questions/513801/programatically-creating-entire-unity-games.html I have a client who would like to create an entire game ...
0
votes
1answer
43 views

Random Y Axis Movement Within Set Limits (C#)

I've searched everywhere for this answer but everything I find is in Javascript and a lot of it doesn't help/work in my situation since most of it is Vector3's and using each axis, and my game is 2D. ...
2
votes
1answer
294 views

Why will my server not execute a command sent by the client in Unity 5.1?

I'm working on a very simple/basic client-server networking program, the basis of a future game I hope to create. Now the client program/project DOES successfully connect with the 'server ...
2
votes
1answer
54 views

Unity C# Object Scaling when parenting by script

How do I make it so an object doesn't scale with another object that I parented it with by script? If anyone knows how to get around this I would really appreciate it. This is the part of the script ...
0
votes
1answer
46 views

Logical Dependencie Problem [closed]

I am working with Unity and C#, but my Problem is a more general programming problem. I am trying to keep things easy, but still make them global access able and easy to modify. So I have a ...
0
votes
1answer
24 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
80 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
127 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
43 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
42 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
42 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
73 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
85 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
152 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
39 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
92 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 ...
0
votes
1answer
89 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
178 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 ...
1
vote
1answer
152 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
62 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
75 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
90 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
87 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
107 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
28 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
42 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
23 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. ...