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

XNA makes the console flicker

I create a Window XNA game project from the template in Visual studio 2015. Then I right click and set the property to console application because I think it is convinient to use Console.WriteLine() ...
0
votes
1answer
64 views

How do I hide UI canvas in c# Unity3d?

I want to display the final results at last in the game when gameobjects finish the winning(finish) line. For that I am using canvas and in that a panel onto which an image is attached. I have to hide ...
0
votes
0answers
45 views

Custom game loop entirely in the Update method

I am attempting to implement a custom game loop in XNA/Monogame. I know that one can re-implement the Game class using WinForms (with the caveat of having to also redo the content manager, etc.). I ...
0
votes
0answers
40 views

Apply Pixel Perfect by script in Unity?

How can I apply Pixel Perfect by script in Unity? All I could find on the web is this which does help at all..
0
votes
2answers
36 views

How can I change my RangeAttribute during in my script?

I have an int which I want to be between 0 and an unknown number. This unknown number is max in the example below. I want this max number to change when another number changes in the editor. How ...
1
vote
1answer
57 views

Creating a Slide-Up Menu

How can I create a menu that slides up while "un-fading" as illustrated in this video? As you can see in the video, the menu also falls down a bit in the end which gives it a realistic feel. I ...
0
votes
0answers
29 views

Turning a game into a server-client game

I'm redoing a game i wrote in XNA to Unity. The XNA game was the client to a server I wrote as a console application. How does Unity work with a server exactly, and how do you set that up?
0
votes
1answer
47 views

Creating placement grid in Unity

I'm fairly new to C# and Unity, so I don't really know much about it. I want to create an RTS like game where you have a huge grid that the whole world is placed on. Then you can place houses, walls ...
0
votes
0answers
23 views

How to use OpenTK (OpenGL) with MonoGame?

So I've been making a snake game using MonoGame (DirectX Only). I added movement, controls, feeding and growing in length. I wanted to add smooth animations to the game because the snake is just made ...
0
votes
1answer
44 views

Monogame - NullReferenceException on Exit();

I'm currently attempting to learn the Monogame system. I have little prior experience in C# (about two weeks of XNA, four years ago) but am reasonably familiar with VB.NET. Essentially, when calling ...
-1
votes
1answer
51 views

Player controller script rigidbody velocity?

I don't understand how this works. How does this code go about manipulating the player's rigidbody velocity? Can you explain it piece by piece? //Movement public float speed; public float jump; float ...
0
votes
1answer
140 views

How can I make my tiles fall smoothly?

I'm working on a Tile-Based game and I can't figure out how to make my tiles fall down smoothly like in candy crush. All column tiles fall-down at the same time. And spawn new like how many tile place ...
1
vote
1answer
78 views

How should I store a procedurally generated grid level of an infinite size?

I have a 2d grid level. It infinitely grows. If it was not of infinite size, a 2D array would be perfect, as I need to constantly have each grid talk to its neighbors. For example, with a 2D ...
0
votes
0answers
16 views

How to pass a java string variable from android activity to unity3d C# script variable?

Require some help to pass custom autogenerated text from android activity to unity3d activity being started.
-1
votes
1answer
46 views

My character just floats up into the sky

So this is the code I'm using for jumping. The character just floats in to the sky. I'm making an infinite runner. using UnityEngine; using System.Collections; public class PlayerControl : ...
1
vote
1answer
64 views

MonoGame does not generate xnb from png

I am coming straight from XNA and I installed the latest version of MonoGame today (2015-12-22) for Visual Studio 2015 Community. I created a project from the windows Project template. I right ...
3
votes
1answer
77 views

Function, that is searching for nearest enemy Transform only works sporadically. What am I doing wrong?

so I am trying to implement a "Zelda"- or "Dark Souls"-like z-targeting system. You'll see in the code, that the function compiles a list of every enemy in the current scene. I'm still in the ...
1
vote
1answer
58 views

Why transform.find() does not need actual object[unity]

I m new to unity and C#. I suspect that transform.find() function below does not need actual object reference like player.transform.find() because it transform find is already applied to the ...
0
votes
1answer
42 views

How to refresh andoid photo gallery in unity

After saving a screenshot into the folder i cannot view the screenshot in the android gallery but can see the screenshot in the folder created.Is there anyway i can see it through gallery?
0
votes
1answer
109 views

How to find connected groups in a 2D grid of tiles

Firstly, my English is very bad, sorry for this. That's why I showed my problem with a picture. Block[,] sameTiles = new Block[ WorldController.Instance.World.Width, ...
0
votes
0answers
54 views

Update the Android Gallery after take a screenshot from android device using unity3d

Currently we are working on "Update the Android Gallery after take a screenshot Here follows our issues: The problem is that we are having a button,when we click on the button the photo gets saved in ...
1
vote
0answers
20 views

GL.Scissor not working as expected

I have some code for rendering a button in an application and I want to clip the text if it's wider than the button itself. Here a bit of code to describe what I'm doing: ...
-4
votes
3answers
114 views

How do I increase the speed of an object after it spawns?

I'm trying to increase the speed of a game object based on the wave it spawns in. How would I go about doing this? public class GameController:MonoBehaviour{ public GameObject hazard; ...
0
votes
1answer
34 views

Why is my counter not incrementing when OnTriggerEnter is called?

I have a script that handles the destruction of game objects based on what they collide with. I am trying to count the number of objects destroyed when they collide with specific objects. However, ...
1
vote
3answers
203 views

Can't parent the standard FPSController during gameplay

I'm parenting the standard assets FPS controller during play with a simple script. The controller get's parented but also instantly inherits the rotation of the parent. This doesn't happen in Editor ...
0
votes
1answer
22 views

XNA 2 3D Objects Depth Convergence Error

Gah! I have a scene with 2 3D objects - a plane and a sphere; the plane sits on the xy axis with a depth if -100 and diameter of 200; the sphere diameter is 32 and sits on the xyz = 0 position; ...
0
votes
3answers
59 views

Math.Clamp won't limit my position until movement is ceased

The program is in a top down view, with Y going up (or forward depending upon how you see it), and X going from left to right based on the camera view. I am attempting to set the minimum and maximum ...
0
votes
1answer
58 views

Make Camera Bounds

I'm new here and I have a question. (Help me Google Translate). At first I make camera from this video. First video First script (CameraController) using UnityEngine; using System.Collections; ...
0
votes
6answers
217 views

How to stop jumping again when character is in air (double jump)?

I'm using touch inputs in my game to control the character. I would like to know how to disable my character from jumping again in the air. if (FingerTouchy.phase == TouchPhase.Ended) ...
0
votes
0answers
44 views

How can I record and play curves in Unity?

I need record and play curves for playback in My game. for example:I want always record xposition curve(for 50 frame) and when game over happen curves will load. public AnimationCurve ...
0
votes
1answer
53 views

Invoking a common method after a button press

I want to implement a common method that handles several numeric values and performs and action based on those values. So I have buttons with specific methods to change this values without affecting ...
-1
votes
1answer
42 views

How to optimize movement script using CharacterController component?

I've made a very basic character controller using a CharacterController component. I'm still a beginner so I keep learning new things. My problem is how to optimize my controller script. Also, I would ...
2
votes
2answers
68 views

How can I access to all component of a certain type in Unity?

I want access to (for example) all AudioSources in Unity and stop all sounds. using UnityEngine; using System.Collections; public class StopAllSound: MonoBehaviour { void Start() { ...
1
vote
0answers
80 views

Dual Contouring - what is it and how to use it?

I'm having trouble understanding Dual Contouring yet and I need some explanations from someone who has first hand experience. I searched all I could before writing this question. I've already read: ...
-14
votes
1answer
349 views

How can I “squeeze” a game object when it is pressed between two others?

I am trying to "squeeze" a game object when it's pressed between two other objects (e.g., "squeezer 1" and "squeezer 2," below) that continue to move towards eachother. I wish to reduce width of the ...
0
votes
1answer
18 views

Trouble GamePad input on iOS but works perfect on Android

I am having trouble getting input from on iOS devices (iPhone 6 Plus and iPad). Here is my code, if (Input.GetKey (KeyCode.JoystickButton14))// A { chr_show = "A"; } if ...
0
votes
2answers
62 views

How to make my Object Zig Zag

I have an object in 3D space with a certain height (y) component that I wish to remain constant. The object is a rigidbody, kinematic, affected by gravity and a trigger. So I tried this method ...
0
votes
2answers
94 views

What is the most efficient technique for range detection?

I have a bunch of patrolling enemies that fire projectiles when the player is in projectile range - a specific radius. Which method is the most efficient and elegant? overlapSphere sphereCast ...
-3
votes
2answers
150 views

Random AI Movement

So I'm creating a zombie game where the zombies are passive and just walk randomly all over the area when player is not near. My question is: how would I make zombies move randomly? I code in C#. ...
1
vote
1answer
50 views

Start Menu Does not Work

On starting the game, a basic startmenu should load. startScreenUI is the background image, and startUI is the buttons for "play" and "exit". I set Time.timescale to zero in Awake() so that the time ...
0
votes
0answers
30 views

How to create custom editor script only for one field of an object and leave the rest default in Unity?

I have a script attached to a game object. The script has many public fields and I'm satisfied with how Unity displays most of the fields for editing in the Editor. Except for a few. I'd like to write ...
-1
votes
1answer
41 views

Combining Pause and Start Menu

I got my pause menu working by using this code: using UnityEngine; using System.Collections; public class PauseMenu : MonoBehaviour { public GameObject pauseUI; private bool paused = false; void ...
0
votes
1answer
39 views

Basic Moving/Anim Script [Unity CSharp]

So, I got this to do the anims for my sprite in Unity 2d... using UnityEngine; using System.Collections; public class Move : MonoBehaviour { public float Speed = 2; Animator anim; // Use this for ...
0
votes
1answer
53 views

Keeping camera at player's back

I'm developing a 3D game similar to the Roller Ball game from Unity's tutorials mixed with a runner type game like Subway Surfers. The game uses the arrow keys for control. When the player hits the ...
3
votes
1answer
65 views

How do I expose a field with a generic class to the Inspector?

I have some utilities implemented as generic classes. I would like to have fields of these types exposed to the inspector but they appear to not display. This test code: [Serializable] public class ...
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
72 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 ...