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

How do I let a game support different rule sets?

I'm making a MUD game engine that supports D&D , Pathfinder and other tabletop-RPG rule sets. I am starting to build out how characters interact with the world (e.g. dialog, battle, searching for ...
0
votes
1answer
37 views

XNA draw texture/font and DrawIndexedPrimitives at the same time [duplicate]

When i Draw a texture2d or a font with spriteBatch and also draw GraphicsDevice.DrawIndexedPrimitives, the frame is draw weird SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice); BasicEffect ...
0
votes
1answer
79 views

Help with understanding “transform.root.GetComponent<>” in Unity

I'm reading through a tutorial for making an RTS in Unity, and in certain scripts it wants you to make a Player field and then OnStart(){ transform.root.GetComponent}. I am not quite getting what that ...
0
votes
3answers
109 views

Drawing 3D cubes with xna

I managed to draw a 3d cube using triangles like this: protected override void LoadContent() { basicEffect = new BasicEffect(GraphicsDevice); VertexPositionColor[] ...
3
votes
2answers
191 views

How can you subscribe to Unity input events, instead of polling for them

Been trying for days to figure out if there is a way to subscribe to keyboard/mouse events in unity. Instead of having to poll for them every frame and make my own events. Right now I poll through ...
5
votes
4answers
812 views

Creating an in-game time system only works with real time

I'm trying to create an in-game time system. Thus far it only works properly if you use 1440 minutes to the day (realtime), but I would like to be able to alter the day length to something like 10 ...
1
vote
2answers
139 views

Unity prefab script “GameObjects” can't be ones on the scene?

Currently, I have an object on the scene, and one in prefab. I want the prefab's script to reference to the object on the scene through the public GameObject obj; code. However, when I tried to ...
0
votes
2answers
98 views

Accessing colliders from one script C#

I want to access specific colliders(to see if they are been clicked) from one script insted of making multiple scripts for every collider.How? I am using unity. using UnityEngine; using ...
0
votes
1answer
67 views

How can I add banking and rotation to this object manipulation script?

I have made a drone script that allows user to move in four directions and ascend/descend. I found a nice tilt snippet which makes the thing bank when it moves. However, when I include this, the ...
0
votes
1answer
87 views

Rotate camera keeping player not in the middle

Here I have a 2D top down game. Currently the camera is set on the player position. The player constantly points to mouse position. I want to modify this setup having the camera to be set slightly ...
0
votes
1answer
52 views

Multiple models not drawing

I got Camera, Terrain and player working, moving around, etc. When I try to add another player (another model to draw) it just dont any of the models. Here is my code; public class World { public ...
0
votes
2answers
143 views

Drawing image with an angle

Edit: the images below aren't supposed to have whitespace. I am just trying to show you that i am trying to create a rectangle from a 1x64 image, positioned as shown in the second picture I know how ...
0
votes
1answer
135 views

Lightning bolt effect with particles is not continuous

I am Drawing a lightning effect animation using this image: Below the result: As you can see the outcome is not a continuous purple color as I wanted it to be, but it has black spaces in ...
-1
votes
1answer
71 views

How to remove the jitter from my pong AI movement?

I am developing Pong using Monogame / XNA and my AI paddle is really jittery when the ball is moving more horizontally than vertically. My AI is very simple and works as follows: If the ball's ...
0
votes
0answers
56 views

Unity Height Field Fluids

I am trying to implement the fluid simulation in the slide deck found here in unity. http://matthias-mueller-fischer.ch/talks/GDC2008.pdf I was able to implement what is found on page number 2, the ...
0
votes
1answer
77 views

How to check a value from the last frame, while using events in Unity

What I am trying to do is check if a value has changed from the last frame, while using events. Typically I could use threading to my advantage and have a check at the bottom of Update() to see if a ...
0
votes
0answers
47 views

Farseer physics engine: save world simulation and load at a later time

I have created a windows desktop game using monogame and the Farseer Physics engine (FPE 3.5). In this game I would like to the user to be able to save the game and continue at a later time. When I ...
0
votes
1answer
350 views

Unity 4.6 UI Replace Images on selection in List of buttons[i]

I made a list containing all the buttons in the UISelectionCanvas and would like to change each image as it is being selected. The problem is once the selection selects a new type of unit it will ...
2
votes
1answer
103 views

Client-Server Game Communication (w/ Protobuf, Relevancy and Delta Compression)

So, I have reached another problem while trying to implement my client-server communication. From everything I've read there are three main ways to minimize packet size: Only send what has changed ...
0
votes
1answer
52 views

Add XNA math references to non-xna project

I'm developing some game with server/client structure, and the client will predict the movements, but it should be validated by the server. In the client part, I got it moving nice, but now I'm trying ...
0
votes
1answer
79 views

How can I load another form containing a new level when my player reaches the current level's exit?

I am coding a very basic side-scrolling game in C#, using Windows Forms. I want to connect my game's levels with 'exit points'. When the player touches an exit point, a new form should be loaded ...
0
votes
0answers
12 views

Separate each model part by “CRTL+MouseLeft”

I have a model,I want to separate each part of the model by using "CTRL+Mouseleft.I have done the part separation by clicking on each part.Now I need to separate each part by "CRTL+MouseLeft".How can ...
0
votes
1answer
30 views

How to rotate model 180º with XNA

I got a model, and a camera pointing at this model, I think my camera position is the problem. Its showing the front of the model, but I want it to show its back like in third person. My camera code ...
0
votes
1answer
121 views

How to make a model parts glow one after the another

I have a brain model. I want to glow the parts of the brain model one after the another after a period of time. I have done to glow the parts, but when the second part glows, the color of the first ...
0
votes
1answer
84 views

Accessing Canvas and Button components in a scene

I have a scene with the following hierarchy: This is game scene and the game manager is a singleton with the following variable fields: // canvas public Canvas PauseCanvas; public Canvas ...
1
vote
1answer
276 views

How can I merge multiple sprite into one sprite or texture using Unity3d?

I have an avatar generator where someone can create a custom avatar with layers superimposed. And in order to reuse this image multiple times, i want to merge all layers in one image. Is there any way ...
0
votes
1answer
148 views

Play continuous music when swapping between multiple scene in Unity3d

I have the following scenario Main menu scene containing a gameobject with an audio source component An about us scene gameObject script : using UnityEngine; using System.Collections; public ...
1
vote
1answer
541 views

Changing color of UI Text in Unity into custom values

There are a few objects in the scene as well as a title. I want the title to change its text and color based on the object that is mouse-overed. The script below is added to each object that is ...
2
votes
3answers
224 views

2D Smooth Tile Lighting

I am currently working on a 2d platformer and have the general idea of how to apply 'lighting' to my level, but I am not sure at all how to make it smooth, similar to Terraria, as you can see here. ...
0
votes
2answers
78 views

How to make a gameobject Scale up from another GameObject script

hi there im having a rought time with this code, trying to make a gameobject grow in scale from touching this one, and when a set amount of scale is reached destroy this game object ( the one who ...
0
votes
1answer
45 views

Array Rectangle Collision Handling Inconsistency XNA 4.0 [closed]

I made a simple collision detection prototype.Here's the code for the Player class's collision handler: public void handleCollision(GameObject OtherObject) { ...
1
vote
1answer
56 views

XNA texture garbage collection

I use a Dictionary<string, Texture2D> for storing textures and every texture in the game is a reference to a texture from this dictionary. However when all references are gone, does the ...
0
votes
1answer
58 views

Issue with fps limiting in XNA

The game I am making runs at 60 fps, but occasionally it will drop lower than that. I want to limit the frame-rate to 30 fps so that those drops will be less noticeable. I don't understand everything ...
0
votes
1answer
72 views

Implementing Client-Server Delta Compression (with Protobufs)

I am writing a 2D real-time RPG in C# and I am trying to implement client-server communication using protocol buffers. I am trying to figure out how to implement delta compression to reduce message ...
2
votes
1answer
71 views

Event error: “…can only be called from the main thread”

I have some custom networking classes which I'm trying to use in a unity game (c#). The network class raises events, which I want to subscribe to in the game code. However, whenever I try to do ...
1
vote
1answer
194 views

Resetting a level in unity when exiting to main menu

I have a pause screen in my game having two buttons : resume game and exit to main menu The main menu have only 1 button wish is play, when i click on exit to main menu the main menu level is ...
1
vote
0answers
40 views

Incorrect Texcoords for Bitmap Font? [closed]

I am writing some code to display text using a bitmap font. However, when I run my game to see my results, I am greeted with a blank screen. I changed the texture to pure white to see if it was even ...
5
votes
5answers
2k views

How can I test whether points are within a polygon?

I have 2D-points, which boundaries depict a polygon. The points are at integer positions (no fractions possible). Now I want to build an enumerator in C# that returns all points that are inside the ...
0
votes
2answers
309 views

How do I create a simple clickable button?

I've tried to attach this function to the play button. public void Play () { Application.LoadLevel("Scene1"); } I've created an empty Game Object and attached my script to it. But when I go to ...
0
votes
1answer
79 views

give a prefab clones a script from another prefab in Unity3d

I have the following : TurretBallmanager : using UnityEngine; using System.Collections; public class TurretBallManager : MonoBehaviour { // Use this for initialization public GameObject ...
0
votes
1answer
49 views

Unity: Object is underneath another object but shouldn't be

I have a simple collision detection program. The red object is controlled by the user and the yellow object is always moving up and down: However, when the objects are supposed to collide, the red ...
1
vote
2answers
68 views

XNA/Monogame inverting a BoundingBox

I have a box that is drawn around my game that I want to check collisions with. Currently my BoundingBox is made in a way that whatever is inside the box is colliding with it: BoundingBox bb = new ...
1
vote
0answers
95 views

Make FPS Controller in Unity suitable for Touch? [closed]

I have a standard fps controller in my app that is controlled by default via mouse. What is the best way to make it touch friendly? Is there something that needs to me modified in the FPSController ...
0
votes
1answer
101 views

Where to store service urls for a Unity3D game

I have URL information for services (dozens of them) that I want to store in a Unity3D web player project. What is a good practice for storing it. (please don't say hard coding them) I've recently ...
0
votes
0answers
76 views

Converting from global coordinates to position in an array

I'm working on a minecraft style voxel game in Unity, and I keep having problems trying to work out how to convert from the global coords to the position in the 3d array used to store blocks. I'm not ...
0
votes
1answer
260 views

MonoGame: Draw thousands of quads without hardware instancing

In my game, every bit of geometry is a textured quad billboard in 3D. I have many thousands of these things on screen at once, sometimes with overdraw. As I understand it, there are a few ways I can ...
1
vote
1answer
54 views

Torch fire always up regardless of handle direction

I have a prefab from some asset pulled into our project. It is a simple torch.. handle and a particle system for the fire. Works perfect if mounted on a wall and torch angle adjusted no problem. ...
0
votes
1answer
67 views

Handling image size based on different ios device versions (Unity2D)

This game is built using Unity 4, C#, and the 2D toolkit. In the unity game scene settings, it is set to (ios 5 tall) and I matched the Menu background dimensions with the dimensions of an ios 5 tall ...
1
vote
0answers
54 views

Having unity game saved to SD card can't run on certain devices but after it's moved to phone memory it works.. why?

A game I made ends up not being able to run (it shows the loading screen but after that it gets stuck), happens on nexus 5, sony experia z3 and I found this happening because the game was downloaded ...
2
votes
1answer
157 views

Unity's StartCoroutine funtionality inside a .NET Library and outside a MonoBehaviour

This code is used in a MonoBehaviour script in my current code: // a simple WWW post WWW www = new WWW(this.Url, bytes); StartCoroutine(WaitForRequest(www)); } // simple handler for the ...