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
0answers
123 views

How should we begin to create our 2D Tower Defense? [closed]

Me and my friend are going to make a 2D Tower Defence game as our last assignment in highschool that has to be finished april/june next year. We both know a handy bit of Java and C# but our game is ...
0
votes
1answer
32 views

Collision in EdgeCollider Unity

I want to make a collider for a line that I've drawn on the screen using mouse. so the detection should be cover the whole line that has drawn. What I've learned from edge collider is you can have ...
4
votes
3answers
494 views

Unity 5 disabling a script

I'm using Unity 5 and want to disable a script called Unit based on whether the instance is a client or a server. I have tried using: GetComponent("Unit").enabled = false; However I get hit with ...
0
votes
1answer
29 views

GUI.DrawTexture problem in Unity

I'm having a problem with GUI.DrawTexture() and I'm looking an alternative function to draw 2D Texture Images. The problem I have is that my textures draw above all other objects and when my camera ...
-2
votes
1answer
50 views

I cannot move a gameObject in my scene

I am trying to move a cube to the right in my scene with this piece of code, but it does not work. What is the problem? using UnityEngine; using System.Collections; public class Jump : MonoBehaviour ...
0
votes
2answers
107 views

How to design programatically a game map like Risk?

I'm making a quiz-game based on map territories with a system similar to the Risk game (except there are no tanks but tickets). The map isn't the world but a custom map that I designed and I'll ...
0
votes
1answer
54 views

Monogame/XNA Making animations play once per click

I'm currently making a #gbjam entry and everything has been going smoothly up to this point. My issue being that I've implemented a shooting mechanic and along with it an animation to play as a shot ...
4
votes
2answers
147 views

Best way to handle cornering in a 2D maze game?

I want to implement smooth cornering in a grid, much like Pacman moving in his maze. A big difference with Pacman, my characters can stop- thus the player has to keep pressing the controls to keep ...
1
vote
0answers
16 views

How do i change the vertical fit of a constant size fitter?

How do i change the vertical fit of a constant size fitter? For example changing vertical fit from min size to unconstrained. Is it posible to do this?
1
vote
1answer
21 views

Unity 5.x - Editor only constructor/initilization event

I have three scripts: Level - Represents a Tile Based level. LevelEditor - Custom Editor for Level. Tile - A non monobehaviour class for storing tile information. Level contains an array of Tiles ...
1
vote
1answer
21 views

Strange anomalies when using WinForms with XNA

I haven't seen any questions related to my issue, and this leads me to believe I'm missing something minor, however; The Problem I'm creating a game that is effectively launched from a windows form. ...
2
votes
1answer
51 views

How to move on iTween path when a button is clicked

I have set the iTween path and also I have added a button. When I click on the button the object should start moving along the iTween path.But issue I'm facing is when I run my project at initial ...
1
vote
4answers
60 views

Moving Object on One Axis

Hi Im trying to move some 3D text on one axis, but for some reason it moves on 2 with this code. Can someone explain why this is/ how to fix it? Maybe this is a simple solution but i cant find it. ...
0
votes
1answer
50 views

Background Scrolling like Zelda - A Link To The Past with XNA [duplicate]

i am trying to create a background that scrolls like the one in zelda - a link to the past. in other words: i have a bigger "screen" than the camera covers, so i need to scroll over it, when moving. ...
0
votes
1answer
18 views

Having trouble with a trigger zone. How do I make it so that it deletes certain objects, but ignores others?

I'm trying to setup a system where I pickup an object drop it into a zone, and then the object is destroyed. So far I have: using UnityEngine; using System.Collections; using UnityEngine.UI; ...
0
votes
1answer
34 views

Sound Effects on Monogame delay

I have recently added some Sound Effects to my game, but the problem that I am dealing with now, is that they have for a half of second delay, or more sometimes. Also, if I press repeatedly on that ...
2
votes
2answers
57 views

Instantiation of a GameObject not working for a threading reason

I receive the following error "INTERNAL_CALL_Internal_InstantiateSingle can only be called from the main thread." "Constructors and field initializers will be executed from the loading ...
0
votes
0answers
45 views

AssetBundle not working properly

I am using Unity 5.0.1. I have created the asset bundle of a sprite by selecting the name "img.unity3D" from the dropdown and then running the script : BuildPipeline.BuildAssetBundles ...
0
votes
0answers
24 views

Enlighten interfering with smartfox user objects

This code is checking if a userID matches any id in a SFSUser List: foreach(GameObject element in connectedPlayers){ if(element!=null) { ...
0
votes
1answer
30 views

UNET Error handling

I am trying to handle errors received by a UNET (new Unity3D networking) client. The below code successfully connects to a server when it is present, but obviously gives a timeout error when there is ...
2
votes
3answers
33 views

Get OnMouseDown to work with a 2D Polygon Collider

I'm having a hell of time getting a 2D polygon collider to register a mouse click. I've attached images and code to show where I'm at. I cannot get the click to work. Ultimately, the thing I'm trying ...
1
vote
2answers
76 views

How to check if grounded with rigidbody

Does anyone have a better way to make an object with a rigidbody check for ground and then jump, right now I wrote a script where a raycast is cast downwards and it checks for distance but then I ...
1
vote
1answer
96 views

How to change the transparency of an object in Unity c# scripting?

I have laser-object in my scene, which I want to be seen only when I press the 'E' button on the key board(just an example of a key). I have seen many ways to change the transparency , however, none ...
4
votes
3answers
197 views

3D Object not drawing in Monogame

I'm quite new to working with 3D objects. I'm currently trying to get one to load in Monogame. The object itself was imported into Blender and exported as an fbx file (which was the only file type I ...
0
votes
1answer
28 views

Instantiation of multiple objects with varying velocities

I am looking to multiple objects of the same prefab at the same time with varying velocities. public GameObject prefab; public float xDirection; public float yDirection; void Update () { ...
0
votes
3answers
62 views

2D Physics friction on a moving platform?

I have a few basic platforming mechanics going on in this scene. I have a prefab platform with an animation that loops back and forth between two different x positions, but does not begin looping ...
0
votes
1answer
31 views

My GUI stopped working?

Okay I bought this asset online so I would like not to show the whole script. The problem is this asset stopped working when I updated from unity 5.0 to 5.1.2. The script is for a controller GUI ...
1
vote
2answers
85 views

How to know from which direction there is a collision with an object? In Unity C#

In the game, there is a ball, and moving objects that can hit it. I want the ball to move when an object hits it. But the ball should move to the right direction, the one which the collision was from. ...
0
votes
0answers
25 views

Position is not what it should be when attaching fixture

In XNA / Farseer I have something like this: Body body = BodyFactory.CreateRectangle(world, 1f, 2f, 1f); FixtureFactory.AttachCircle(0.5f, 1f, body, new Vector2(0f, 1f)); I have been told that ...
0
votes
1answer
28 views

Stop player following cameras cameras direction

Okay I'm not going to go to much into it but this is what I need my script to do. The way I have my controller set up is that the camera looks to the side of the player a little bit. I use this for ...
-2
votes
1answer
39 views

Save the screenshot of the scene locally in unity

I have a unity project which contain a button in the scene. I have loaded a terrain also into the scene. When I run the project, the terrain and the button will be shown. When I click on the button, a ...
1
vote
1answer
31 views

Drawing Farseer Fixtures

Is there any way how to draw a Polygon / Fixture from Farseer Physics with XNA? As I deform these polygons at runtime I can't take any texture from my Content folder, the texture must be generated at ...
0
votes
1answer
44 views

SerializeField vs GetComponent Efficiency

As far as I know, there are two built in ways to get an instance of a component in Unity. 1 - Serialize the field and drag in the component manually in the editor [SerializeField] private MyScript ...
0
votes
1answer
53 views

FPS horizontal smooth camera rotation

I have a problem, my camera is parented to the FPS Controller prefab, then there is a script I wrote for the rotation of the player horizontally by mouse movement, it all works but the rotation is ...
-4
votes
2answers
37 views

I want to now how to set. X to a spot and change it to a cord but. Keep my Y and Z [closed]

Let's say postion was X1 Z34 Y2 I want to move char to X2 no matter what Z or Y are I want to change my x and keep z and y the same and keep momentum
1
vote
2answers
87 views

How do I refer to the object that called a function?

I have a large number of buttons instantiated from a prefab using a loop, as follows: public void LayoutButtons() { GameObject newCanvas = Instantiate (canvas) as GameObject; for ...
1
vote
3answers
74 views

Move ball based on direction of force?

I'm trying to make a ball that will move in the direction I push it from, and later pull it to me based on where the player is standing. using UnityEngine; using System.Collections; public class ...
0
votes
1answer
33 views

Finding enemy object in player's forward direction within a range

I would like to know the way by which I can find enemy objects tagged with "player" in a forward direction within a range say 3 units from the player.
0
votes
1answer
38 views

Card/Tile Game, loops dont update element0 of playerHand properly

The Problem I am dealing from another class and into a player's Tray(A class with a List of Tiles and an array of bools to show that a slot in the tray is full). When dealing into the player's tray, ...
0
votes
1answer
36 views

Unity - Jump counter for double jump script not working? C#

It was working fine last night but it doesn't work today, the zJumpCount stays at zero after I jump now. If the zJumpcount stays at zero my double jump code doesn't work. I even ctrl+z'd back to the ...
0
votes
1answer
57 views

Unity5x GetComponent<Animation>().Play(“sequence”.StopAll) not working

I'm working with Unity3D 5x using C#. I've attached collision detection to the character controller script that plays a "gothit" animation clip (using legacy animations). Here are the code snippets, ...
3
votes
2answers
222 views

2D Collision Detection XNA C#

I've read all around the net, watched videos, tried things and in the end I can't make a decent platform collision detection. I've followed this tutorial. It didn't work out at 100%. My object stops ...
1
vote
0answers
29 views

Google Play Games Signs Out Automatically without Internet Unity

I am using this in my game to implement games saving and loading. I have also tried the basic sign in process by using the following start function :- { PlayGamesClientConfiguration config ...
1
vote
1answer
85 views

Real-time movement client to server to client(s)

So the way that I tried to create a MMO like server communication was by sending strings to every-player containing information and making the client split the string. Example "John" , 42, 64 : ...
-1
votes
1answer
25 views

Right-side weapon rotate to face the mouse target

I have a 3D game looking from top to bottom where I move the mouse to aim at targets. I have a simple box (the player) with a sphere on its middle-front (that is the pistol) and a cylinder on its ...
0
votes
1answer
62 views

Best way to manage weapons as GameObject on a script in Unity with C#

I have a player game-object with a script Player. In the Player script I have a public properties weapons. I want to have to just drag in this properties a script/prefabs. And the Player script must ...
0
votes
1answer
78 views

2D Infinite Runner: how to manage the generation of dynamic terrain? [closed]

I'm creating a infinite runner game with Unity3d, i've been using math to generate the terrain by calculating the size/pos of the terrain and place the new one next to it, and it's working correctly, ...
2
votes
1answer
75 views

How animated block in voxel engine?

In my voxel engine (XNA 4.0) I'm use a vertex buffer for the entire chunk and update it after the set block, changing block metadata or light level. This is not too frequent operation compared with ...
1
vote
2answers
167 views

Render sprites onto a virtual 640x480 “screen”

I'm making a game, and in part of it, the player uses a computer terminal. I want to draw to a virtual 640x480 screen with pixel precision, and then draw that "virtual screen" to the player's real ...
1
vote
5answers
123 views

Advice on how to store level design info? [closed]

I'm building a 2D tile-based puzzle game in C#, using Monogame. The game board is an 8x6 grid of tiles, each of which can contain a number of objects. Conveniently, the number of possibilities for ...