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

11
votes
1answer
821 views

Does `yield return false;` have special meaning in Unity3d C# scripts?

In Unity, we have some special things for coroutines that are additional to normal C#. for example, we can use yield return WaitForSeconds(5.f); to have a coroutine wait 5 seconds before ...
5
votes
2answers
401 views

Set a 2d camera's position so that a building is under the players feet

My issue is this: i am making a scrolling game in XNA, and the camera updates based on the players velocity, but the player never actually moves, he is always in the center of the screen. When he hits ...
6
votes
3answers
227 views

How do I generalise Bresenham's line algorithm to floating-point endpoints?

I'm trying to combine two things. I'm writing a game and I need to determine the grid squares lying on a line with the floating-point endpoints. Moreover I need it to include all the grid squares ...
1
vote
1answer
212 views

XNA Monogame GameState Management not deserilaizing

I am having some trouble serializing/deserializing in a little game I am doing to teach myself monogame. Basically, I am using the gamestatemnanagement resources common to monogame (screen manager ...
5
votes
1answer
620 views

Should the networking of my game be a component or a service?

I am working on a windows game and I am trying to understand the XNA GameComponents and GameServices classes and use. From what I understand about a component is that it has an Update method that ...
0
votes
1answer
78 views

Multiple joysticks event handling

I want to make a game which is totally same idea as "Who pressed the button answers the question". I have 2 joysticks and both are connected to a pc. My application will be Winforms and I will ...
2
votes
2answers
117 views

Mandelbrot generation using custom HLSL shader in XNA

So I made a Mandelbrot generator in C# and I'm learning about HLSL and custom shaders in XNA (For a college course). I was hoping to do the mandelbrot calculations on the graphics card to make them ...
0
votes
1answer
130 views

Angled topdown perspective camera for 2.5d game

I have a 2d tile based game created using Unity's 2d tools and orthographic camera: The tiles are created by programmatically generating a mesh, assigning a texture to each pair of triangles, and ...
1
vote
1answer
40 views

XNA Veiwing cubes behind others

I am learning 3D at the moment. It is going well but I am stuck on the viewing of the camera. I have two cubes, one next to each other made up of vertices, all the faces/triangles in the cubes are ...
1
vote
1answer
48 views

How do I measure a string that will be drawn with SpriteBatch?

Is there a way to measure width and height of an ever-changing string (a player's score, specifically)?
0
votes
1answer
56 views

How to inplement a save-system for a complex nested list of character classs?

This is the situation I'm in: I'm developing a game with C# using unity. In the game I have characters which is either locked or unlocked, and they're pretty much the same. For every character, they ...
0
votes
1answer
53 views

Collision detection doesn't register until player sprite jumps

I have implemented a shooting mechanic into my game, and the act of shooting works fine. The shooting work is done in my "game1" class. The issue that arises is when I incorporate collision detection ...
0
votes
1answer
43 views

How can I determine where to show a nameplate over a character?

I'm working on a naming system that displays the name of enemies above their heads. The problem is that I have some enemies that are larger or smaller than others. So I'm trying to use a function ...
0
votes
0answers
20 views

How to create a board with evenly spaced pieces in unity? [duplicate]

Creating a board should be easy but I am having a difficult time doing it in unity because of its world coordinates. I need to create a board that will have squares evenly spread out across the ...
0
votes
0answers
42 views

How can I create a 2D camera with zoom and parallax scrolling that works on every Windows Phone resolution?

Mario game that uses parallax scrolling: http://www.youtube.com/watch?v=de5f3mvRyIY I want to create a Windows Phone jump-and-run game with parallax scrolling. The parallax scrolling should be like ...
1
vote
2answers
49 views

XNA graphics.PreferredBackBufferWidth's new value doesn't immediately change window size

I set the width and height of the window in my game constructor, and then pass the graphics manager to a class to check the value. In the game's initialize function, it doesn't seem to recognize the ...
1
vote
1answer
81 views

why am I being unable to access public array of a class inside other class? [closed]

I know this question has been asked before but my case is different(or i could not gather any kind of help from those) I am facing "NullReferenceException: Object reference not set to an instance of ...
1
vote
2answers
195 views

Unity - OnDestroy - When is it called?

I was wondering about the method called OnDestroy in Unity (4.5.2f1) on Windows 8.1 Update 1. I know garbage collection in C# in non-deterministic, so I was wondering if game objects had OnDestroy ...
0
votes
1answer
79 views

Find world matrix

I'm making my first 3D-game with XNA (MonoGame) and have come to a point where I wish to add a crosshair for the player. To do this I need the on-screen coordinates of the location where my fighter ...
0
votes
0answers
40 views

Add terrain collision and fix axis of camera

I made 3rd person camera script which works ok but needs few tweaks which I don't know how to fix. I'm using controller/ joystick. -Firstly, camera has this issue: when I look at the back of the ...
1
vote
1answer
121 views

Sever Structure for a Turn Based Game (Chess) [closed]

I am working on a Turn-based Game (Chess) I have done the client part and single player mode so AI is no problem here. But the only problem is now I want to make my project multiplayer. I have done ...
0
votes
1answer
47 views

Can't consistently add to TimeSpan for Unity Game

I'm making a game that has a timer showing how long the player has survived from being crushed by pessimism. (Long story) I'm trying to use TimeSpan in Unity to accomplish this but it seems that I'm ...
0
votes
2answers
79 views

Switching a project written in Lua to a compiled language [closed]

I am experimenting with game development in Lua using the Love2D framework, and while it works fine, I am getting tired of using a dynamic scripting language. I would like to have better performance, ...
-1
votes
1answer
41 views

Object reference not set to instance of an object Unity3D c#

public class player { public projectile pro; pro = GetComponent<projectile>(); void Update() { GameObject go = GameObject.Find("enemy"); Transform ...
16
votes
7answers
3k views

Is there any Lua API that works with C# for PC & XBox 360 Development?

I am reading a book on Game Development in which they show you how to make scripts for your game in Lua. They program Lua and use it from C++, but I was wondering if there is a library or API to use ...
0
votes
1answer
41 views

Getting Target position at the time of shooting

I have a bullet that has to hit a constantly moving enemy. So, in BulletScript, I have declared a Transform public Transform enemy; //and assigned enemy object to it that is ...
1
vote
2answers
39 views

C# - Collision Detection problem with platforms on Monogame(XNA)

So I am having issues with my platformer that I am developing. I can detect collisions fine when there are a line of parralel blocks or even single blocks. The issue I have is when blocks form an L ...
1
vote
2answers
75 views

Loading and storing content efficiently

So for example I have a class called TypingKeyboard. It allows you to display a string while it's being typed by the computer with sounds. I need one in the menu, for the title. And one for the ...
0
votes
1answer
31 views

XNA - Autodeploy .exe of game upon succesfull commit to GIT

I know of ClickOnce which creates an .exe file so a user can play my XNA game. However, I have to manually go through a wizard in order to create this file. I would like for the new .exe to be ...
-1
votes
1answer
120 views

How are grids made?

I've been looking at tutorials and researching forums and such but I still can't understand how the grids are made. I get confused at parts like this. for (int x = 0; x < Size.x; x++) { for ...
0
votes
1answer
55 views

What is the optimal way to handle matrix internal data storage for interop with native graphics apis?

I'm writing a managed (c#) game engine and have stumbled on a bit of a crossroads in design/implementation regarding matrix types. Matrix types need to be optimized for marshaling to native graphics ...
0
votes
1answer
35 views

GUI Label shows on screen when object is out of view?

I have GUI Labels over NPCs in my game, and the labels display their name above their head. But when I walk away and go somewhere else, their names stay on screen like it's mirrored or something? ...
0
votes
1answer
111 views

Automatic Movement

I am making my very first GAME in Unity 2d. At the moment my game consists of 2 walls a floor, a ceiling, and a square which represents the character. After watching some tutorials I have created a C# ...
0
votes
2answers
160 views

Problem with moving player through a secript by a set distance

I am currently trying to add a sort of "dash"-ability to my sidescroller. What I try to do, is to let the player press a key where a simple key-press causes the player to move quickly into one ...
0
votes
1answer
296 views

Monogame: Why is my sprite looking the same on every resolution?

I want that my sprite(Mario) don't look the same on every Windows Phone resolution. If I use this code, the sprite is on every resolution on the right position but it also has the same size on every ...
1
vote
1answer
113 views

Automatic Left/Right movement

First 2d game in Unity. Started Character controller in C#. Tried to get the character to move constantly right then once it hits the wall move left without needing any input from the player. Looked ...
11
votes
6answers
15k views

How to handle mouse input in XNA?

I am developing a card game in XNA. Is there any OnClick event in XNA for objects? I am trying to make cards move when the player clicks on them. In this project, there is a Sprite class that draws ...
0
votes
4answers
153 views

Timing of coroutines in Unity is never precise

I was looking an official example for coroutines in Unity here. However, when I call WaitAndPrint the time taken is never exactly 5 seconds. IEnumerator WaitAndPrint() { float timeStart = ...
1
vote
2answers
106 views

Simple square hit the wall and turn around without stopping

I am coding and making my very first plat former game in Unity 4.5 2D. Basically I want my character to ping pong between two walls. I have set up a GroundCheck and CeilingCheck. I was thinking to ...
1
vote
1answer
50 views

Listen for asset modification in editor

I would like to listen for an event that some asset (prefab, precisely) has been modified. To my surprise, there's no such event in AssetModificationProcessor. Is there any way to do this in Unity?
0
votes
1answer
155 views

Binary Serialization of C# for GameObject in Unity?

I'm trying to serialize a GameObject (with children and textures) using the binary serialization for C#. It works with many data types but not with GameObject. In the docs it says should be ...
1
vote
1answer
64 views

How can I determine whether a unit is in range or not?

I'm programming a small game that's going to be somewhat like a tower defence. I was playing around with how I determin whether a unit is in range or not. public void Update(GameTime theGameTime) ...
1
vote
2answers
103 views

Drag an object in unity3d

I want to drag an object to a perticular place.In case I release that dragged object before I reach that particular area ,the object should come to its initial place where i start to drag. How it ...
1
vote
1answer
266 views

Fast, simple procedural 2d island generation

I need to generate tile data for an island based rpg, my goal is have something that looks like this (mountains not required): For the past few days I have been trying to figure out a satisfactory ...
0
votes
1answer
45 views

Detect which key was pressed last each frame

Why hello there, im developing a 2D game using XNA. My character movment is currently based on the keyboard state. Example (in the right order): if (state.IsKeyDown(Keys.W)) { //Do ...
1
vote
0answers
37 views

How do I setup scoring system for my game? [closed]

I've created a simple endless game. And I want the scoring system to be something like the one in flappy bird. My aim is to publish my game to app stores in the end. How do I save/keep a high score? ...
-1
votes
1answer
557 views

Matchmaking system in Unity

I was wondering, how would one go about making a matchmaking system in Unity? I've tried some ideas with the Master Server, but it wasn't doing its job right, since thats a lobby based solution. I ...
7
votes
5answers
2k views

Is C# different in Unity?

Does Unity use a different version of C#, or is it all the same? It looks different from regular C# but there are some regular C# elements in there.
0
votes
0answers
36 views

Change the object when the object is clicked [duplicate]

In the above image, there are different icons for New, Open, Save, Save As and alternative images for when you click the icon. I have placed these images onto game objects. In the above menu when I ...
2
votes
1answer
3k views

Should I use XNA or Unity to build a video game? [closed]

My friend and I are planning to make a video game (like Slender) where the character is stuck in a building, when lightning strikes, and the lights go out and your objective is to find the back-up ...