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

Trying to use yield to wait for a few seconds to avoid the sounds from Interfering with each other

Ok so when my player hits a wall (Enemy tag). My player is destroyed after a certain amount of time. During this time, I disabled the mesh renderer on impact so it "appears" as if the player is ...
0
votes
1answer
37 views

Distance based item interaction

I'm having an odd issue in my implementation of distance based object interaction in Unity. Basically it's a simple "Press [key] to [search/pickup/open/etc]" function which requires the player to be ...
0
votes
1answer
73 views

In Monogame, why does Rectangle.Offset not work?

I have the following code in a default Monogame Game project: protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Left)) { ...
1
vote
1answer
164 views

Standard Assets Cross platform joystick sensitivity

I am using the standard asset joystick that comes with Unity 5, the sensitivity changes depending on the device used, for example on an Samsung S3 it is more sensitive than on a Nexus 7 2013, how can ...
2
votes
1answer
40 views

How do I expose a field of an abstract type to the Inspector?

I have a class hierarchy with an abstract parent class. I would like to have a field of this type exposed to the inspector but it appears to not display. This test code: [Serializable] public ...
0
votes
1answer
45 views

Randomize sound in Unity 5

When I start my game, public AudioSource does not load sound but play a sound. My code does not have any error. using UnityEngine; using System.Collections; public class random: MonoBehaviour { ...
0
votes
1answer
66 views

Collision problem with multiple tiles (rectangles)

I think that I found what the problem is, see below So I'm working on a collision system and I use multiple tiles in my project, each with a collision box. The player also has a collision box. I'm ...
0
votes
1answer
50 views

How to Implement a Timer for my Prefab for Roll-a-Ball Game (C# in Unity)

I am trying to create a public float timer that senses when the particular prefab has not been there for a certain amount of time. Then, it will replace that particular object. The goal is to ...
0
votes
1answer
78 views

Why is FindObjectOfType(MyType) not finding anything?

Why would I get the following log? Start OpponentMotionReceiver motion receiver not found true public class ScoreAnimation : MonoBehaviour { private OpponentMotionReceiver ...
-5
votes
3answers
177 views

Making game totally from scratch [closed]

I'm used to make my games in Java. Java is an awesome language but to launch .jar files you need a good updated JRE. So I thought: "I'm just going to make my games in C# or C++!" Unfortunely, I can't ...
3
votes
3answers
105 views

Is it a bad practice to add helper methods if the class is intended only for data? [closed]

For example, if I have something like: class ItemData { public int cost; public int level; ... public List<ItemData> childItems; } And I'm aiming to separate ...
1
vote
2answers
113 views

How to restart the game when pressed enter in XNA

If the following code allows the game to exit when pressed esc .. if (gamePad.Buttons.Back == ButtonState.Pressed || keyboard.IsKeyDown(Keys.Escape)) { this.Exit(); } Then this code should ...
1
vote
3answers
97 views

Unity: How to manage a large amount of prefab variations?

The project that I'm working on demands the ability for game designers to be very flexible when balancing, customizing items, etc. The most difficult requirement to meet at the moment is that they ...
7
votes
2answers
208 views

2D A* Path-Finding

I have this problem, which isn't really a problem, but I feel like it's some sort of glitch in my code maybe. My pathfinder, to find a path from A to B, does this: which is almost fine, it works ...
2
votes
3answers
84 views

How can I avoid instantiating multiple instances of a RigidBody?

I could use a little help. I've a state machine for an NPC that does a melee attack. The problem I'm running into is that the current code instantiates multiple instances when I only need one per ...
4
votes
1answer
49 views

How to link the game class to the main menu class in XNA?

So I got my game in another class and my main menu in another class. This is the update method in my Main menu class MouseState mouse = Mouse.GetState(); switch (CurrentGameState) ...
1
vote
0answers
33 views

Scale texture at runtime in unity

I need to scale the texture in unity3d.In unity we are able to adjust the scale using the option in the toolbar How will I scale the texture at runtime using the mouse pointer. the texture should ...
0
votes
1answer
32 views

Updating score in collision detection game in XNA

I created a collision detection game in XNA but I have a problem with the scoring. As online tutorials says, I initialised it score = 0; This is in the update section to check if the person hit ...
0
votes
2answers
109 views

Gyroscope Parallax Effect In Unity

I want to make a parallax effect in Unity 3D with gyroscope like the one on this site: http://matthew.wagerfield.com/parallax/ I found an asset, but it is too expensive. So I need a script which I ...
0
votes
1answer
32 views

Why this if logic isnot short circuiting?

I've this script in UNITY to check if the hit RayCastHid2D variable has some gameobject with hole tag or a parent gameobject with hole tag when I Raycast... if (hit.collider != null && ...
2
votes
1answer
43 views

Rotating object around a rotating one?

I am developing a solar system animation in Unity3D. Planets rotates around sun. But ı have an issue simulating satellites like Moon. Moon should be rotating around world normally and moon should be ...
2
votes
1answer
62 views

What's the best way to make multiple objects of the same thing?

I am coding in C#. Due to limitations of the environment I will be working in, I cannot use any framework like the XNA Framework; only what is provided by default on Windows. I want to create ...
1
vote
1answer
62 views

How to remove destroyed clones out of the Hierarchy in Unity2D

I made a 2D edge collider which on contact destroys the other gameobject. When I launch the game all the other gameobjects in fact get destroyed but the clones are still listed in the Hierarchy. How ...
0
votes
2answers
56 views

How to draw the elements that are in a Texture2D list in XNA

I have a Texture2D list called blockTexture that has 2 elements in it. I use the following line to draw the first element. foreach (Vector2 blockPosition in blockPositions) for (int i = 0; i < ...
1
vote
0answers
48 views

Screenshot preview freezes a game for a few seconds

I have a screenshot preview at the end of the level, but when I show it my game freezes for a bit(low fps for a few seconds). This is code I use to load screenshot and crop it(for a little preview ...
-2
votes
1answer
65 views

Cannot clone game object in Unity C#

I am having a bit of an issue with getting an empty bullet shell to clone every time a bullet is shot. The first empty shell appears and drops, but after the first empty shell, nothing is cloned. I ...
1
vote
1answer
67 views

Display mesh in front of camera

Im trying to display a mesh in front of the camera and FACING the camera ( I'm developing an small editor in wpf using helix3d). Pretty much something like this question I load my mesh into a ...
2
votes
1answer
72 views

Implementing attack animation in four direction movement

The way the program is supposed to run is basically, a character can be running/idle and if spacebar is pressed, all movement stops and movement controls are locked through the bool "canMove". The ...
0
votes
2answers
26 views

Ingame notification - Windows Phone

Im working on a simple game for windows phone. There is one item in the game where the player can click on a enemy and shoot him. Well there is a 1:2 chance for the user to shoot the enemy and when he ...
2
votes
3answers
246 views

2D Game has very bad lag because of one script?

I am making somewhat of a flappy bird clone (mostly for practice) and everything works fine, but it is just really slow with a low FPS of 13 and a max FPS of 28. Why would this be? So I ran a check ...
1
vote
0answers
76 views

How should I store battle effects?

I have battle effects that can be anywhere from 50-150 frames (running at 60fps). I need to be able to draw each frame of the battle effect as an additive layer onto my game. A frame could look ...
2
votes
0answers
110 views

Building an Octree for terrain generation

I've previously implemented marching cubes/tetrahedra to render an IsoSurface. It worked (YouTube), but the performance was dire as I never got around to implementing LoD (or even removing distant ...
2
votes
0answers
52 views

Unity: Create a custom editor for Vector2

I'm starting to dig into Unity's editor customization. What I'm looking for is a way to create custom line (or a point at least) which I could move around in SceneView and set a Vector2 value that ...
0
votes
1answer
42 views

Blender model doesn't show up in monogame

I have a problem getting blender models to show in monogame on windows. Using latest monogame 3.4, fresh blender 2.76b, developing in Visual Studio 2010 using OpenGL Monogame template. What I'm ...
1
vote
1answer
86 views

How to code sprite sheets?

First of all, the XNA Framework works on my computer, but I do not wish to use it for reasons. I am set with the task of coding my own sprite sheet class. I do not know if a class is the best way to ...
2
votes
1answer
37 views

Find your value between four values in a grid based on distance, Unity

Please note: Originally posted in stack overflow, redirected due to nature of problem. I am making a procedural mesh game. I am trying to calculate the temperature for the player's current chunk by ...
0
votes
1answer
62 views

Unity - Random Spawned Enemy Is Not Moving

I want to make an enemy spawner with random rotation left and right in unity. Its an 2d platformer. The random rotation is working, but the enemy is not moving after it's spawned. I put the rigidbody ...
0
votes
0answers
33 views

C# - XNA blurring tiles despite using PointClamp SamplerState

I´ve a problem drawing isometric tiles without getting pixel issues. The way I do it is the following: SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, ...
2
votes
1answer
50 views

Multiple overlapping rectangles

I have a collision method where the parameters for the method are the rectangle of the player and a list with the rectangles of the tiles. I work with booleans like bLeft, bRight,... and this ...
0
votes
2answers
71 views

Why cannot I show Interstitial ads?

I have tried many things but I could not make interstitial ads display in Unity. I want to show interstitial ads after users select a wrong answer and before the score page ("Notice" scene) displays. ...
1
vote
2answers
66 views

transform.Rotate needs to change axis of rotation

So I'm making a game in Unity. After many failed attemps from either being bored of the idea, or something going wrong and me giving up I think (hope) that will be the good one. I have made a simple ...
0
votes
1answer
46 views

Saving with PlayerPref problems

I'm having troubles saving how much of an item I have in my game. Right now I have it so the price goes up the more items you buy, that works, but every time I reset the game, the count goes back to ...
0
votes
0answers
29 views

How can I create a character for a 2D platformer in Farseer Physics 3.5?

I want to create a similar character like in this tutorial. http://www.madgamedev.com/post/2010/09/09/Article-XNA-Farseer-Platform-Physics-Tutorial.aspx But the tutorial doesn´t work for Farseer ...
0
votes
0answers
26 views

How do I set an array of matrices in HLSL?

I'm trying to render skinned meshes using Direct3D9 and HLSL. I am getting unexpected results due to the transforms that are bound to the shader. I am using PIX to view the constants and the values ...
0
votes
1answer
56 views

FPS camera up and down control

I am new to Unity. Now I am working with FPS camera. While pressing a key down arrow I want my camera to go down and again it come back to normal position. I am not getting any idea how to do it. ...
2
votes
1answer
33 views

Collision method only using one item from list

I've made a temporarily method for collision with all the blocks on the screen. (I used almost the same method in the past, but only for one block at the time.) So I start in the Sprite class. I use ...
-4
votes
2answers
106 views

Unity Renderer.bounds issue?

I would like to make rend.bounds.max.y be always equal to 20 on collision no matter what, using the script below. But it seems that I can't set it manually and the script has no effect on my ...
-3
votes
2answers
88 views

My Simple Score System Isn't working please help [closed]

using UnityEngine; /// Handle hitpoints and damages public class HealthScript : MonoBehaviour { /// Total hitpoints public int hp = 2; /// Score System public int score; /// ...
2
votes
1answer
70 views

Unity3D Pathfinder with Crossings

I'm trying to bring traffic on my street system. The main problem for me are the different lanes and crossings and to make it complete the different types of paths. I've tried a bit with the ...
5
votes
2answers
543 views

Can you write the current frame number to a text file?

I am running an experiment in Unity 5 to see the effect increasing the particles of a particle effect has on FPS over time. (this is background work for a much larger piece of work). Currently I write ...