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
2answers
35 views

How do I have a camera follow my object in Unity?

I have an object that automatically moves by itself and I want the main camera to automatically follow it.(Like in games such as geometry dash and jetpack joyride) This is the code for the automatic ...
0
votes
0answers
16 views

Unity 2d make character move perpendicular to ground [on hold]

I am trying to make my 2D character move perpendicular to the ground but I am having no luck I need him to be able to jump freely but stay perpendicular to the ground when grounded only.
0
votes
0answers
18 views

C# XNA Weird black line behaviour of sprite animation spriteBatch.Draw()

So I've been making a Space Invaders game in XNA. I have my ship spritesheet (sprites are left-to-right - horizontal). The spritesheet has 6 sprites. Here's my class: playerShip.cs using System; ...
0
votes
2answers
41 views

c# Unity - Matrix output incorrect on vector rotation

I have a input Vector (1,1,0) when I run it through a Unity Matrix4x4 class with a rotation of 90 degrees around the Z axis the output is (-0.9999999,1,0) which is nearly correct but strange. But ...
0
votes
1answer
70 views

How can I allow players to draw decals for their avatar and items?

I want the player to be able to draw a simple symbol, even if it's pixelated black or white, that their character can have on their weapons, armour, forehead or even markers and monuments. How would I ...
0
votes
1answer
26 views

Trigger scene loading in one device from another device using Unity WWW class

I have a master device and client device. I want to load a scene in the client device by pressing a button in the master. My method is, when the button is pressed in the master device, a data is ...
0
votes
0answers
30 views

bool keys 2 players with c# [on hold]

I'm working on my project and have a question. I have to make a multiplayer race game. I have to cars that have to race vs eachother, the only problem is that it have to work on one keboard. I can ...
-1
votes
0answers
54 views

Creating a large game over time. need help understanding something [on hold]

I don't want to explain the whole thing but I've been wanting to create a game that will grow into something very large meaning it will hold a large amount of game content. The way I can explain it is ...
0
votes
0answers
31 views

Choppy Character Movement Unity 2D [on hold]

I am new to game development and have been following a tutorial to get started, it is a flappy bird style game. My main issue at the moment is when tapping the screen to move my character it is ...
2
votes
0answers
30 views

Why is OnCollisionEnter2D called when it's layer's collisions are being ignored?

I'm sure this is down to my lack of understanding of the unity physics system. I'm trying to implement a simple one-way platform for a 2d game and have got stuck on creating a reliable way to let the ...
0
votes
1answer
33 views

Copying a texture's colors to a new texture to create a new sprite

Let mySprite be some .PNG sprite: Texture2D tex = mySprite.texture; Sprite sprite = Sprite.Create(tex, new Rect(0,0,tex.width,tex.height),new Vector2(0.0f,0.0f),1.0f); The resulting sprite can be ...
3
votes
2answers
91 views

Find a position within one radius, but outside other radii

I have an Object A which will attempt to stay within a certain distance of another Object B. I would like Object A to also try to stay outside a certain distance of one or more other Objects R. ...
0
votes
0answers
18 views

XNA C# - Get original rotation from parent bone transform

I have a 3DS Max made model, exported into FBX and imported into XNA project. The parts I am working with have NOT been rotated in Max (specifically, collision mesh is made of Axiz-Aligned boxes). ...
0
votes
0answers
42 views

How to move vertices of matrix in order to cast a 2d shadow?

I am trying to add shadows to my 2D xna game. Currently I have created a "shadow" using the texture of the caster with a transparent gray color, rotated, and stretched using a matrix. This, though, ...
0
votes
1answer
72 views

Alternative to Update()

Here is my noobish scenario I'm trying to understand: Some class, Terrain: void Start() { ... switch (Type) { case TerrainType.StartPoint: ...
-2
votes
0answers
43 views

How to check the Intersection the line and triangle in 3D [closed]

For example there is a code: struct Point { public int X; public int Y; public int Z; } struct Triangle { public Point p1; public Point p2; public Point p3; } struct Line { ...
0
votes
1answer
74 views

Why does GameComponent have an Initialize() method?

I'm not sure if this exact question has been asked before, but all I could find were questions about how to work with GameComponent, or why something wasn't working. I understand that you overload ...
0
votes
2answers
67 views

How to write an adjacency algorithm that compares position data?

I have a list of indexed triangles for which I need to generate adjacency data. I've already written a brute force algorithm that creates 3 edge data structures for each triangle and then compares the ...
0
votes
0answers
19 views

XNA: Does the position of mouseState matter? [migrated]

In order to get a single click response from MouseState, I use this line. currentMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released) And at the ...
0
votes
1answer
46 views

Xna 2d tile culling

I'm trying to make a simple 2d tile engine here, and I've got a problem with getting a proper cells from a tile grid map when I'm trying to cull off tiles which aren't needed to be drawn. I've got a ...
0
votes
1answer
40 views

C# - How to properly play background songs in XNA

So I'm using the game states (enum) to change my game screens. I have 2 songs for main menu and game playing states, respectively. To play songs, I'm using an old code example I saw at MSDN, like ...
-4
votes
1answer
64 views

Move an object based on XML/TXT file [closed]

Let's think I have an file which looks like this: 0 1 2 3 4 5 6 7 8 9 10 11 I want to create a move from this file. For every 1s(mentioned in the file) I want to move the object. Is this ...
0
votes
0answers
33 views

Share image on selected media [closed]

I want to share image on selected media that I capture through code. At present I have following code to capture image private void CaptureScreenShot() { Texture2D tex = new ...
1
vote
3answers
182 views

Issues with ECS performance

I'm currently implementing ECS in "classic" sense, as defined by this wonderful post, where we have Entities, Components and Systems. And I'm having a serious (for me) performance issues. They come ...
0
votes
0answers
64 views

How to create a sun (shining) and a moon in a 3D world? (Using specular light.) [closed]

I'd like to know: where should I start from to create a moon and a shining sun. Do I need 3D models or is there an effect I can use? Or is it better to use a sprite? Actually, for now I just have a ...
0
votes
0answers
38 views

How to move rigidbody player to its facing direction with AddForce?

How can I move a rigidbody to its facing direction? I've already tried this: rigidbody.AddForce (transform.forward * v, ForceMode.Acceleration); // v is a public float which gets a new value in ...
0
votes
2answers
68 views

How to make a wait timer?

I am making a mining styled game and am looking to make variables that effect how fast you are able to mine the block. This is the idea I have currently got but it does not wait for the timer to ...
0
votes
2answers
59 views

Incrase framerate in XNA [duplicate]

I'm trying to increase the frame rate of my game from 60FPS to 100 FPS because of reasons. But i can't seem to get it higher than 60 frames. This is the count I'm using. I can slow down the frame rate ...
2
votes
1answer
103 views

Should I bother merging faces in my 3D block-based game?

Okay, so I have a bunch of cubes in a 3d-world. I already implemented face culling, so that when a cube is next to another cube, their touching faces won't be drawn, or even sent to the buffer. ...
2
votes
2answers
602 views

Slow dictionary access with coordinates as keys

I am making a game server and currently I am experiencing a huge performance hit. I have a class Map which holds a Dictionary of the class Tile with each tile having X, Y, and Z coords, some lists, ...
-3
votes
1answer
34 views

Move the Object in y-axis when the timer increases [closed]

I have a model(.Fbx object),I have placed a timer.When the timer starts increasing the model/object should move down(along y axis).
1
vote
1answer
58 views

How to find the 3D object the camera is pointed at

I'm currently developing a 3-dimensional game (the first I've ever done and it's not as hard as I thought it would be!), but I've run into a little bit of a snag. I want to find the current block the ...
3
votes
2answers
177 views

How to calculate left/right oriented angle between two 2D vectors? [duplicate]

I would like to calculate angle between two 2D vectors. Here's a picture of what I'm trying to achieve: I have an obstacle line segment AB and incoming moving PC. If I'm coming from one side C¹D¹ ...
0
votes
1answer
46 views

Calculate needed speed and object's position in Unity3d

So i'm trying to calculate object's future position so my enemy can land to it safely. Idea is that using future postion I can calculate angle and convert it to direction vector and also using ...
4
votes
1answer
83 views

Odd Behaviour XNA Game Component

Inside of my main class file I am initializing a number of game components which are used to represent game scenes i.e. main menu and game. I am initilizing each component inside of XNAs LoadContent ...
0
votes
1answer
46 views

XNA C# 3D game Wall collision response glitch

I have been working on a reliable physics system in my code and so far it's ALMOST working. :D I am aiming for wall "sliding" style of collision response, like you'd expect it to work in commercial ...
1
vote
4answers
122 views

How to read a data from text file in unity

Can anybody help me out with giving the steps needed for reading data from the text file in unity and how can the script be added.
0
votes
0answers
51 views

Emit light from items

In order to create a day/night cycle in my game, I decreased the r,g and b values of the Color variable after a certain amount of time has passed. This worked as expected. I am wondering in order to ...
0
votes
1answer
89 views

2D object grids to a dictionary

I'm pretty new to Unity and trying to figure out what a good way of transferring objects in a grid to a dictionary would be. For example, if i have a grid of 2D objects (squares) such as below ...
0
votes
1answer
42 views

Creating a Player object in a physics engine

I have a working physics environment using Farseer - but how do I create a player object that can walk around? My current attempt involves applying forces to a rectangular body whenever keys are ...
3
votes
2answers
264 views

Why should I use a list of enemies instead of an array of enemies?

I have been making 2d shooter similar to galaga using xna in C#, where the enemies (2 types) are all in rows above the player's ships, and are supposed to randomly launch attacks. I had previously ...
0
votes
1answer
44 views

GLSL: Vertex attribute to int

I'm trying to write a shader which renders a multitextured geometry wihout rerendering the geometry with each texture. In my test I'm not using textures, I just convert the texture index to a color ...
0
votes
0answers
34 views

Handling menu input in the GameStateManager sample

I've been trying to get more customization out of the GSM sample and i'm a bit lost. I've made a new method in InputState.cs that returns true when a key is being held down. This is for scrolling ...
2
votes
1answer
44 views

How can I tint a Texture2D with a gradient?

I am working on a lighting system for my game. Instead of lighting each tile completely with only one color, I want to create a gradient on that tile so to make the lighting look more dynamic and ...
0
votes
0answers
23 views

Drawing quadtree nodes

I'm using a quadtree example that I found on a tutorial. I have initialized the tree and using a breakpoint I am able to determine that there are 4 child nodes, each containing a number of items. So I ...
1
vote
1answer
29 views

How can I fill a Color[] from a Texture2D given a Rectangle in SharpDX?

I used to fill a Color[] using XNA's Texture2D.GetData<T>(int, Rectangle?, T[], int, int) method, but there doesn't seem to be an equivalent overload on SharpDX's Texture2D. Anyone know how I ...
1
vote
1answer
21 views

XNA Texture.GetData “Size of the data passed in is too large or too small for this resource.”

I am attempting to retrieve the color data for a given sprite located on a texture atlas by creating a new color and passing a source rectangle width and height for the given sprite. I am then passing ...
1
vote
0answers
70 views

How do I implement melee hit boxes for a top-down game?

For a 3D top-down game, how should I handle collision in melee combat? My game has no targeting system, so I can't use a simple distance check between attacker and target. What I am thinking is have ...
0
votes
1answer
53 views

Remove item after crafting

I'm having one last problem with my crafting system. Say an item takes 2 rocks, 1 twig, and 1 vine. When I craft the item, only 1 of each item is removed instead of the correct amount of items related ...
1
vote
1answer
45 views

Use of SpriteFonts without installing on host machine

I am working on a Windows game for my university project. In this project I am using a custom TrueType font which is not installed on any university computers. For submission my game is required to ...