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

3
votes
1answer
25 views

How to edit and persist serializable Assets in the Editor Window?

I have an asset saved in my project which represents a serializable scriptable object. Code of the object is very simple: using UnityEngine; using System.Collections; public class TestScriptable : ...
1
vote
1answer
34 views

Programatically Build List of Custom Class Objects (prefabs)

This seems like it should be a simple thing, but I cannot seem to figure out a method. Currently, I have a public List<MapGraphItem> roomList variable, and in the inspector, I add prefabs from ...
1
vote
2answers
40 views

Randomly instantiate avoiding overlapping in Unity 5

I'm starting a 2D game where I want all the letters A-Z displayed in a random position and, then, the player collects them all in the correct order. I need to randomly instantiate the letters without ...
1
vote
0answers
256 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
2answers
50 views

Random Functions in Unity [closed]

Is their a way to execute or call a random function in unity. Something like:- void Update(){random(func1(),func2())} void func1(){print("func1")} void func2(){print("func2")}
-1
votes
0answers
34 views

Toggle between positions in Unity [closed]

I am making a 2D game where an object goes up, down or in the middle. I want to toggle between going down, middle or up on left click but it is not working. So basically what is meant to be happening ...
57
votes
13answers
31k views

What C# libraries can be used to support game development? [closed]

As games are based on many different subsystems things like graphics (DirectX, OpenGL, ...), sound (OpenAL, Ogg Vorbis, ...) or physics (collisions, ...), what libraries do you know that are useful ...
0
votes
1answer
65 views

Set input relative to map rotation?

I'm trying to figure out how I can make the input which looks like this : // Checks if player is pressing movement keys, if is applies force to specified direction if (Input.GetKey(KeyCode....
-1
votes
1answer
52 views

What properties should be private, public, and protected? [closed]

I'm currently trying to write a base player class, and I'm not exactly sure what I should make private, and what I should make public. I know that as a programmer, I need to keep as many variables as ...
5
votes
1answer
1k 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 mWorld;...
0
votes
1answer
32 views

2D diagonal movement using Rigidbody2D

I have a problem with 2d player movement, as I am unable to move on the Y-axis. Yet, the movement on the X-axis is working as intended. Below, you can see my code: public Sprite directionUp; public ...
0
votes
1answer
31 views

Transforming position in y-axis (going in the middle) in Unity [closed]

I am making a 2d game where an object goes up, down or in the middle with given Input. But when the object goes to the middle with GoMiddle() it starts glitching and it can't go back up or down ...
0
votes
1answer
346 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 ...
4
votes
1answer
78 views

How do I differentiate between the two Vive motion controllers?

I am working with a Vive Pre (devkit) and I have most everything working the way I want it to. However I am wondering how do I refer to or even know which motion controller is which? From what I can ...
0
votes
1answer
141 views

Creating a Board Game Strictly Using Windows Forms

I'm working on my final project for a Software Design class, and we've been tasked with creating a board game, specifically Risk. Right now, the back-end game logic is functional, however I'm ...
2
votes
2answers
31 views

How to access a prefab's boolean property through collision (with the same Prefab but different Instance)?

I am a trying to recreate the first stage of Super Mario Brothers, but I am having a bit of trouble with the collision system between Koopa Shells. I have written two different scripts in hopes to ...
1
vote
0answers
29 views

Problem in player Rotation in Unity

I am trying to rotate game camera using my android device orientation.Like this Using accelerometer input of device this may be done. But I don't know how to do this. I tried lot of methods, but ...
1
vote
4answers
90 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,...
-4
votes
2answers
89 views

Trajectory Arcs

Ok so I have read this question Calculating trajectory. And it is sort of working in my program. I am trying to produce nice parabolic arcs with this. Like so .. The results I am getting look more ...
0
votes
2answers
47 views

Transforming Position in y-axis (going down) in Unity

I want the gameobject to go down (position.y) after pressing a key instead of pressing the key repeatedly. So in my current code the object goes down(0.05f) each time I press a key. But I want it to ...
4
votes
1answer
91 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 ...
6
votes
4answers
569 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 ...
3
votes
2answers
71 views

How do you restrict sideway movement in 3D endless runner in Unity?

I have been making a endless runner 3d game and implemented 3 lane side way movement. It's working perfectly, although I want to restrict my movement for the 3 lanes only. If my character for example ...
1
vote
1answer
55 views

Physics2D raycasting with a perspective camera and tilted sprites

So i ran into this problem today. I want to have a perspective camera and sprites that are rotated by lets say 1.5 on the X axis. The problem is that the 2D raycast does not work correctly, it returns ...
1
vote
0answers
36 views

Fixing wave-like movements when rotating an object using mouse input in Unity

I have encountered a rather odd issue with my program. The setup: In my scene, I have a GameObject which I have set as my player/character for this game. The player/character has a child GameObject, ...
1
vote
2answers
42 views

Unity Non-shader method of combining two RGB Textures into a single RGBA Texture

I work in a broadcast environment that delivers video signals over SDI as Fill (RGB) and Key (A) signals. My SDI rendering method produces a Texture for each SDI input and applies it to a material. I'...
1
vote
1answer
80 views

Texture Editing with Multi-Threading

So I have this giant Texture2D (4096 * 4096, don't ask why) and all its data stored in an array of Colors. When I hit left MouseButton I create a blue 64 by 64 square at the cursor's position using ...
1
vote
2answers
48 views

Tag for Moving platform

My character is not sticking on the platform when jumping on it but I don't know why. Here is the code: void OnCollisionEnter2D(Collision2D other){ if (other.transform.tag == "MovingPlatform") { ...
1
vote
3answers
287 views

Simple way to shoot bullets from a ship at angles for shoot em up

Just like the title says. I'm working on a shoot em up for a personal project, and I can't seem to get this to work. I don't have any code for it, but I do have the code to make my ship shoot, but ...
1
vote
2answers
277 views

animation control problem

I have a list of .FBX object.When I drag that .FBX into scene its corresponding inspector Animation component(fig 1) appears but when I drag some other .FBX object into the scene the Animator ...
2
votes
1answer
1k views

Adding materials to a Line Renderer through code? (Unity)

I have a material that I am using to add a glowing effect to my line renderer. I can add this as a 2nd material to the line to give it a glowing effect. I want to be able to add/remove this material ...
1
vote
0answers
64 views

Polygon 2D collision response- How do I find the correct edge a polygon hit?

Hey guys I've been seriously stressed out by this, so please go easy on me. My goal is to reflect a bullet (polygon) off of another polygon, and find the edge the another polygon, A (the bullet), hit....
2
votes
0answers
27 views

Frame Skips in MonoGame

I'm developing a 2D game using MonoGame. I've got a square on the screen I can move around. The problem is that about once a second, the square jumps a bit. Using a frame counter I found here I've ...
4
votes
3answers
52 views

Check which object trigger another

Two animated car object both contains rigid-body and box collider and a script with OnTriggerEnter event. Now I want to check that which car hit to another car. Means if A hit to B or b hit to A as ...
2
votes
1answer
27 views

Unity API - Making a Sphere Jump?

I'm making a very simple game with a sphere that's supposed to roll and bounce on "planets". Also, please be ready to read a lot. I want to be very descriptive for you. :) I've pretty-much-done ...
1
vote
0answers
22 views

How to Convert DirectX Texture2D to a DXGI Surface for WPF Rendering?

I have an image in my WPF application that uses a D3DImage to render DirectX content. On the DirectX side I render everything to a Texture2D using SharpDX (a C# DirectX wrapper), but I'm not sure how ...
4
votes
1answer
83 views

Lidgren not starting server properly

I have a server set up for my game with Lidgren, and it works well when I have it set up on one machine, but if I try to run the server on another machine, I am unable to connect from other machines. ...
5
votes
1answer
304 views

How to save the Mesh from an Interactive Cloth at runtime in Unity?

At the start of a scene I have GameObject called 'sheet' positioned above a 'ball' GameObject. The sheet has an Interactive Cloth component on it and a Cloth Renderer. The Mesh for the Interactive ...
0
votes
2answers
1k views

How to make a gameobject Scale up from another GameObject script

I'm trying to make a GameObject grow in scale from touching this one, and when a set amount of scale is reached destroy this GameObject ( the one who scales up the other). My problem so far is that ...
0
votes
2answers
561 views

SceneManager.GetActiveScene(); return -1 when Debugging active scene in editor

I'm trying to use the new SceneManagement since Application.LoadLevel is obscelete and I've read that we need to put it like this. using UnityEngine; using System.Collections; using UnityEngine....
1
vote
0answers
23 views

Third-person Steering with Samsung Gear VR Unity

I am working on third-person steering, where you see the object like car, plane, spaceship in front of you as you steer it. I have got the code for Google Cardboard . How can I implement this in ...
1
vote
1answer
601 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 ...
1
vote
1answer
62 views

Unity 5.3.5 - How to setup a lobby with general game settings?

I am currently working on the lobby for my game. I have followed these tutorials (https://www.youtube.com/watch?v=jklWlm5v21k), which were very helpful, and was able to setup my lobby like this. The ...
1
vote
0answers
13 views

Move around the object using head tracking movement in Unity

I am developing an app for Samsung Gear VR with unity.I have added a cube and made the cube move forward on the terrain. Now I need to move around the cube using head tracking movement.I have ...
0
votes
1answer
188 views

Continuous Jumping Cycle

The script makes a GameObject jump using realistic gravity and reach a specific target. The GameObject jumps relative to the target, thus adjusting its trajectory. It also works while the target point ...
1
vote
0answers
24 views

Monogame intermediateSerializer with winforms

I want my xml files to be game ready on save in my winforms. Right now I am trying to serialize a simple object like this and it is accessing the XML file, but not outputting anything. Am I missing ...
1
vote
1answer
109 views

Animation Scaling?

I have an animation that changes the scale of the GameObject but also happens to change the position as well. I do not want the position to be changed by the animation, only the scale. How can I do ...
0
votes
1answer
173 views

How to stretch screen image to fit higher res monitors set to lower resolutions with Unity?

Using Screen.SetResolution(width, height, windowMode); , how might I stretch the image to match the monitor size? I've noticed this problem occurs both with this line of code and also the default ...
1
vote
1answer
83 views

Unexpected Execution Order in Unity (uNet)

I made a little game in Unity. It works fine in the Editor. But if I run the build version I get a NullReferenceException. This problem does only appear if the build-version-client hosts the game. ...
4
votes
3answers
317 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 ...