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

1
vote
1answer
110 views

MonoGame ArgumentNullException in Spritebatch.End()

I switched my Project from XNA 4 to MonoGame 2.5.1. The port went somewhat unproblematic but I am stumpled across a problem i can't resolve. For your interest, the code worked on XNA: When I am ...
1
vote
1answer
127 views

How to correctly handle multiple movement key presses resulting in double the speed?

I am trying to implement acceleration and drag into my top-down 2D game. The player can move using the WASD keys. Acceleration works fine, but the way I handle the directional velocity causes the ...
2
votes
1answer
90 views

Issues with 2D Body/Limb system [closed]

In my game I have programmed Body and Limb classes. The Body is guaranteed to have an origin in the center of its sprite. The Body class has a List of children Limbs, each with their own offset. Every ...
1
vote
0answers
155 views

How can I use custom shaders in Monogame?

I wrote a shader in XNA and I want to use it in a Monogame Windows Phone 8 project. I converted my Effect1.fx file to Effect1.mgfxo. But the program doesn't work correctly. The screen of my emulator ...
0
votes
1answer
188 views

How to get and change a mesh-renderer component in unity?

I've been making a simple brick-breaker game using unity 4.3 (In C#). I'm currently trying to make the blocks, which are stored in an array, all start with random colour properties. The colours are ...
3
votes
1answer
71 views

Why is my cursor not working if I add a scaling matrix?

After moving the camera to any direction, my cursor isn't getting drawn on the correct position. For example: I move my camera to the right, after that I click on the screen, but the cursor isn't ...
8
votes
4answers
2k views

How to change Gravity towards certain object in Unity?

I have two spheres in Unity. One is 1000x in size other is 1x in size. So I want the smaller sphere to be attracted to bigger sphere. So how do I do it. I know that it can be down through gravity ...
1
vote
1answer
70 views

XNA C# Mario Collide

I'm trying to make Mario so im trying to do the collision part but whenever I do the side collision it bounces back too far. I want to make it so that it only stops Mario not bounces him back. ...
1
vote
0answers
51 views

Setting up 3d Collision for Primitive shapes

Im having some trouble understanding how to set up collision detection between my first person camera and my primitive shapes which are made using the vertex buffer. Do i give my camera a boundingBox ...
1
vote
1answer
65 views

AddComponent using a variable

I want to add a Component to a GameObject using an existing instance of the Component class. Let's say I have the class Foo: public class Foo : MonoBehaviour { int id {get; set;} string name ...
1
vote
1answer
125 views

How can I use a camera matrix with different resolutions?

I created a little jump'n'run game. The character(Mario) is always the center of the viewport. The game is running correctly if I use the resolution 800x480 pixel. But when I use another ...
-1
votes
2answers
137 views

Why is my C# array in unity not working?

I'm creating a 2D brick breaking game in unity 4.3. I want all of my bricks to be different colours for each game, so I've created a C# script to assign random colours to each brick when the game ...
2
votes
1answer
113 views

2D physics rotation w/ XNA

I'm creating a simple game with space ships made of blocks that are all the same size. After having looked at this: Calculating the rotational force of a 2D sprite I have created the following code ...
1
vote
1answer
105 views

How to rotate vertices of 2D shape using a transform matrix?

I am making a top-down 2D game and am currently working on implementing improved collision using SAT. I programmed a Shape class with a Vector2 center that is its position in world space. On top of ...
3
votes
2answers
790 views

Update vs. FixedUpdate in Unity

I was told to use Update() for graphics and FixedUpdate() for physics, but sometimes my inputs won't register when I use FixedUpdate(). It works fine if I use Update() for everything though. Should I ...
3
votes
1answer
1k views

C# XNA Is key toggled?

I've got a question about toggling keys. How do You check if the key is toggled? Here's my quick and easy code: public class KeyToggle { private bool isEnabled = false; ...
1
vote
4answers
222 views

Cell Lighting Propagation Problem

I have in place a cell-based lighting system that works basically like this: (Not my actual code) //Light moves up for (int x = 0; x < width; x += 1) { for (int y = 0; y < ...
0
votes
1answer
105 views

Calculating ball trajectory in Pong

I'm making a Pong game and I'm just looking for a simple way to calculate a straight travelling path for the ball based on the angle of the ball. How would I go about implementing something like this? ...
5
votes
1answer
1k views

How can I export a .FBX file from Unity3D at runtime?

I want to export an object as a .fbx at runtime in Unity3D. I've made a C# script to export a mesh filter or skinned mesh renderer to a .obj file at runtime, but I want the animation and skin support ...
0
votes
3answers
613 views

Basic 2D Enemy AI

This is the basic layout of my game: http://www.youtube.com/watch?v=qcd-CcKWjGU&feature=youtu.be To make him move I just made it so you click left or right to move, just for a test. Anyway, I ...
0
votes
1answer
76 views

How to retrieve a cube collision by faces

I work for a while on a minecraft game (voxel). I am front a problem for a long time about the collision detection. I want recover the cubes collision from my highlighted black's cube like on the ...
9
votes
2answers
4k views

Scripting engine for XNA

Say I'm making this big game in C# with XNA. What options do I have to include a scripting feature to my code base?
2
votes
2answers
82 views

How to use camera transformation without depending on (1,-1) scale during spriteBatch.draw()

I am creating a 2D platformer type game in XNA. I currently have a camera object, with a position/rotation/zoomlevel that I use to generate a transformation matrix to pass to SpriteBatch.Begin(). ...
0
votes
0answers
27 views

XNA - Link between Create Rotations matrices

A friend of mine have been coding some rotations on my XNA project, but the order of the matrices rotation are not good. Some are of form : Matrix.CreateRotationZ(1.21f) * ...
0
votes
0answers
34 views

XNA - Store and define level event [duplicate]

I am currently developing a game in C# using XNA/MonoGame and I face an issue to manage and store my level event. I store my level in XML (Enemies, Spawn location...) and I would like to store my ...
0
votes
1answer
110 views

Tile System with moving Platforms

I am using a tile based system where the level is stored in a char: char[,] Level2 = {{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'}, ...
0
votes
2answers
187 views

SharpDX.Toolkit setting constant buffer

I am trying to use a constant buffer in a program using SharpDX.Toolkit. I use the Toolkit because it has nice font support for writing on the screen. The problem I face is in assigning data to the ...
1
vote
1answer
643 views

InvalidOperationException when using C# DLLs with Unity3D

Description I've been attempting to use a custom DLL in Unity. I've confirmed the DLL runs correctly outside Unity. The DLL imports into Unity and when I refer to it in my scripts, I get no compiler ...
6
votes
2answers
466 views

Detecting Light Intensity Around Characters

Later Edit Since there seemed to be a bit of confusion: I am asking this for purely didactic reasons, I'm not searching for the most efficient solution. Reformulated question: I'm working under ...
1
vote
0answers
49 views

Collision repositioning/resolution help

I've been having a trouble with moving objects out of the hitboxes they've just collided with. Here is my (relevant) code so far: Vector2 oposo = other.position; Vector2 poso = ...
1
vote
0answers
116 views

Could not load sound (MonoGame) [closed]

I am using the Window Project (in MonoGame 3.2) which is uisng DirectX instead OpenGL. If I run a game, so its show me: "Could not load wind asset as a non-content file" I think, that is no ...
4
votes
1answer
390 views

Can't load vector font in Nuclex Framework

I've been trying to get this to work for the last 2 hours and I'm not getting what I'm doing wrong... I've added Nuclex.TrueTypeImporter to my references in my content and I've added Nuclex.Fonts ...
0
votes
1answer
125 views

How to create public Arrays of game objects so that they can be assigned through inspector

I am making a unity2D game. I need to declare public array of gameobjects so that I can assign them colliders, textures through inspector by drag n drop. Is there any way to do this? I am using c#. I ...
2
votes
1answer
488 views

How can I use XNA with Visual Studio Express 2013 for Windows?

http://dev.windowsphone.com/en-us/downloadsdk I downloaded the current version of Visual Studio to develop Windows Phone apps, but I don't know how to add XNA. I tried to install XNA, but it's not ...
0
votes
1answer
114 views

Variable Jump in Unity3d

I implemented variable jumping in unity for an endless running game. My question, how can I make the jump frame rate independent? My algorithm if ( keyDown ){ isJumping = true ySpeed += ...
0
votes
1answer
94 views

How do I prevent clicking at the end of each sound play in OpenAL?

I have put together a basic sound handler class for use in my game. It uses OpenAL. It's a simple method at the moment to play sounds - here's an extract from a switch block: case "EATEN_PILL": ...
0
votes
1answer
48 views

Why do I get an error about being unable to change rasterizer states in this code?

I'm trying to toggle between wireframe and full mode while drawing a 3d model. So far I have this rs = new RasterizerState(); In my update method: if (state.IsKeyDown(Keys.V)) { ...
0
votes
0answers
76 views

Farseer: How can I break a body into multiple pieces?

I created a breakable body but the pieces are not flying around if the ball touches it. What is wrong? Why is the breakable body not breaking into pieces? I made a video and I enabled debugview, so ...
0
votes
2answers
161 views

Farseer: What can I do so that a body can move through a special kind of bodies?

I have three different kinds of rectangles. Black, white and blue rectangles. The rectangles are moving and can collide with each other. But with one exception, the blue rectangle can collide normally ...
8
votes
1answer
221 views

Finding the correct speed for AI to turn to reach goal

I have a ship that travels at max speed maxSpeed and can turn rotationSpeed degrees per second. The ship always moves in the direction it is facing which means that the faster the ship is travelling ...
1
vote
1answer
79 views

How to put basic scripting/variable changes into dialog xml files?

I have a simple XML structure for my dialog between the player and NPCs. What I'd like to do is put variable changes (and maybe other things) directly into the XML. So, for instance, if you select a ...
0
votes
0answers
72 views

class instance issue

Currently, i am working on a project which deals with several parts. First, I want to interface with a Sidewinder Force Feedback 2 joystick in Unity using SharpDX and SharpDX.DirectInput libraries. ...
0
votes
2answers
335 views

How can I make RPC function calls in Unity?

I am making a multiplayer game. I am sending score via the server and client but I want to be sure that can I call an RPC function of a script from any other script. For example, say Table_Manager as ...
6
votes
1answer
196 views

Optimize state changes within a render queue

I am refactoring some parts of the game engine I am working on. This engine is made in C# with XNA. The part I have trouble with is shader/material and the render queue. In the new version I will ...
1
vote
0answers
89 views

SpriteFont not found in Nuclex Framework

I am using MonoGame to port my XNA Windows Phone app to iPhone. All is well except that my fonts look distorted/smudged on the iPhone. Turns out this is due to the way that MonoGame builds the ...
2
votes
1answer
114 views

Adding an object viewer to a Unity Editor Window

I'm wondering if its possible to add an object viewer (For example when you import an .fbx file into unity you can see a small preview of it in the inspector) to a Unity Editor Window? I've looked ...
0
votes
0answers
180 views

Script to intelligently move aircraft using curves [Unity]

I am trying to code a script to move an aircraft entity from point A to point B and at some point in the middle of moving have the aircraft forward vector face Point C (to fire a missile at an enemy ...
2
votes
1answer
222 views

C# - Separating Overlapping Rectangles

I'm trying to separate an arbitrary number of randomly sized rectangles, while still keeping them snapped to the grid, and somewhat packed together nicely. The goal is to start with something like ...
4
votes
4answers
531 views

How can I draw a shadow under my character?

I created a 2D tile-based jump and run game for Windows Phone and I want to draw a shadow under the character. How can I do that? The shadow must also be drawn on the tiles if the character jumps. The ...
13
votes
2answers
2k views

What is the standard C# / Windows Forms game loop?

When writing a game in C# that uses plain-old Windows Forms and some graphics API wrapper like SlimDX or OpenTK, how should the main game loop be structured? A canonical Windows Forms application has ...