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

Handling touch input with Event Trigger

I wrote a simple script to control my 'Player' object: using UnityEngine; using System.Collections; public class PlayerMovement : MonoBehaviour { public float jumpVelocity = 10; ...
0
votes
1answer
964 views

Simple heart container script for 2D game (Unity)?

I'm attempting to create a simple mobile game (C#) that involves a simple three-heart life system. After searching for hours online, many of the solutions use OnGUI (which is apparently horrible for ...
0
votes
2answers
379 views

Unity how to change material properties at runtime

I'm working on a unity game where I want to change the color of a material from within a script. The material applies to a line renderer. I currently have the following script: using UnityEngine; ...
1
vote
1answer
174 views

Questions about scaling in a 2d game in unity

Okay, so: I am making an android game. I want everything to scale to the size of the screen I'm using. Further, my static background needs to scale (as well as every other object), but if the aspect ...
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 ...
0
votes
1answer
194 views

XNA game structure question

I see to be running into a problem here. I know it's easier to show code samples so here you go. This is my main game class namespace WindowsGame4 { public enum MoveDirection { Left, Right, Up, ...
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 ...
1
vote
1answer
230 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 ...
0
votes
4answers
107 views

How to check distance between two different vectors?

So I have a very basic racing game, where I would like the car to stop once it hits the finish line. Respectively when the distance between the car and the finish line hits or goes under 0 the car ...
2
votes
1answer
124 views

How can I mask this CanvasRenderer?

I'm creating a text box that allows for selectable text, based off of Unity's InputField. An issue I am now facing is that the selection highlight does not respond to masks (The parent has a mask, but ...
1
vote
1answer
1k views

Unity 5 How Do I Set Text of Text Component of Input Field

How do I set the text of the new Input Field's Built In Text UI Object in Unity 5+? myInputFieldText.text = "Text Value I Want"; The code above does not work to set the text inside of a ...
4
votes
3answers
495 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 ...
2
votes
4answers
2k views

Modifier System C#

I am trying to figure out a system that can easily modify objects on the fly. For example, lets say I have an Entity2D that inherits from Entity. Entity2D has a Position property. Now I have a ...
4
votes
1answer
954 views

Unity3D [C#]: How do I use a custom inspector to expose an array of polymorphic objects to edit?

[EDIT: based on some feedback, I pruned the example down to the base functionality of the bug we are trying to solve. The description below remains accurate, but the repro has been shortened to: ...
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 ...
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 ...
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
2answers
361 views

Water Physics In top down 2D game

I have been making a game like Minecraft or Terraria in which you add blocks and such to the world, and I came across this interesting debacle, the game is in a top down 2D perspective, and I would ...
0
votes
1answer
29 views

Arrow key control on winforms RichTextBox

I am making a faux console using winforms for the game I am working on. Right now I am moving a '0' across the screen using the arrow keys. In order to provide fine grain formatting on the text, I ...
2
votes
1answer
746 views

How do i define array in shader's constant buffer with C#?

I am using SharpDX to render 3D graphics and i cannot get to work constant buffer in my shader since it contains an array. Currently it looks like this: cbuffer cb0 : register(b0) { matrix ...
-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
3answers
174 views

Unity3D - How do I make so when user moves the camera it doesn't go beyond the scene borders?

How do i make so when i move my camera, it doesn't go beyond the border of the canvas while playing. This is the script i use to make the camera move: if (Input.touchCount > 0 && ...
0
votes
2answers
113 views

[Unity]Making sure playermodel only moves 1 unit

I am doing a school assignment based off of the Unity3D tutorial 2D RogueLike (all code available here) In my version though, the movement is not turnbased and I am having some trouble figuring it ...
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 ...
0
votes
1answer
387 views

When should I set a texture as a shader resource in order to read it?

I'm writing a Direct3D 11 HLSL shader with SharpDX. What I want to do is write the depth to a texture in one pass and read it in the next one. After declaring the texture, do I have to set the depth ...
0
votes
1answer
26 views

Resources.Load doesn't grab values of my child class

I have a parent class Unit, and child classes melee unit/ranged unit. The parent class holds uninitialized fields such as health, damage, etc. the child class sets the values of these fields in an ...
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
2answers
421 views

Create a continuous flight path on a Bezier Curve in Unity3d

I am working on a game in which a butterfly is flying along some path. What I am trying to do currently is create a Bezier curve starting from the butterfly's position(previous curves end point) and ...
0
votes
1answer
37 views

Touch taps only on very short flicks on Win7 with Monogame

I have an application on win7 which needs to support touch and mouse input using monogame. But reading touch taps proves to be a very hard thing. The TouchPanel is initialized like this: ...
0
votes
1answer
165 views

Getting Image name given a canvas WPF

I have a bunch of images I'm using for a chess game in a canvas using wpf, xaml, and C#. I want to use Canvas.SetTop(image, position); to set the position of this image. However I am given the ...
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. ...
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 ...
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. ...
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 ...
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. ...
1
vote
2answers
388 views

Control animation using animator control class

I did a sample existing code to control animation using animation.I dragged and dropped a character into the scene then I added a Animator to it and added the animator controller.Below I have given ...
0
votes
1answer
79 views

How to deal with a many to many relationship between objects

In my game, I keep a list of all clients currently connected to the server and a list of all actors in the game. Each actor is "relevant" ( currently replicating ) to 0 or many clients, and each ...
0
votes
4answers
156 views

Checking if object passed between two other objects

I have a three objects (strikers), lets say red, green and blue. When I apply force to the green object I want to check if it has passed between red and blue or not. See the image below for an ...
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 ...
0
votes
1answer
343 views

How to change the speed of the gameobject moving on the itween path

I have set an itween path for an object to move.And I have written the code as iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",300)); The above code is working for ...
0
votes
1answer
69 views

Unity animation editor having trouble to animate twice the same component

I'm not getting warm with the Unity animation editor. This is what I want to do: The 2 lasers should be like this, rotating 360 degrees over and over. .The classname laser2 doesn't mean anything, I ...
2
votes
1answer
222 views

How to impale and stack targets correctly according to the collider and its coordinate?

I'm making another simple game, a catch game, where a spawning target game object must be captured using a skewer to impale it. Here how: At the start, the falling object (in red) will fall in a ...
2
votes
1answer
461 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
2answers
272 views

How to make legacy animations run in Unity in unscaled time? (Pause game related)

I'm relatively new to Unity, and I've been having a very difficult time getting the legacy animations to run in unscaled time. I need to pause my game, and as soon as it pauses, I need to have my ...
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; ...
3
votes
1answer
2k views

How can I create or extrude a mesh along a spline?

Let's say, for example, that I have a working spline. I want to use this spline to create a mesh, but I'm not quite sure how to go about it. For example, I want to create a road along this spline. I ...
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 ...