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

Why is this comparison not working? [on hold]

I am running a coroutine and experiencing the strangest behavior that I cannot make sense of. I've tried writing the code several different ways but still get the same results. It is really bizarre. ...
0
votes
0answers
25 views

Code for inventory functions not working

I'm working on an inventory, and I've ran into some problems. Some functions in my CollisionDetection class don't work properly. My CollisionDetection class contains functions that involve mouse and ...
4
votes
7answers
1k views

In Unity, how do I correctly implement the singleton pattern?

I have seen several videos and tutorials for creating singleton objects in Unity, mainly for a GameManager, that appear to use different approaches to instantiating and validating a singleton. Is ...
0
votes
1answer
66 views

Zoom at a specific point using Orthographic camera

Currently I can perform Zoom which seems to be working fine but essentially what I'm really trying to do is zoom on a position offset from center as currently when I zoom then zoom is performed at the ...
0
votes
2answers
4k views

Play animation when click on each player with in maincamera unity3d

I have 3 gameobjects (player1, player2, player3). I attached a script "playerscript" to these game objects. In the main camera, I have added another script called "testscript". Clicking on a player ...
0
votes
1answer
113 views

How to load sprite from JSON?

i know how to load text, but idk how to load texture from json.. this my c#: public void soalbegin(){ filepath = System.IO.Path.Combine(Application.streamingAssetsPath, "soal.json"); ...
0
votes
3answers
287 views

Unity FP Character Can't Look Vertically

I have a FP Character and well, it can't look vertically. Its happened about 3 times now, each time I just replaced it with the standard assets prefab, first few times it worked fine, but then after a ...
0
votes
3answers
104 views

A method to create and assign a name to a GameObject (Unity)

I'm trying to create a function that takes in a name of an object in the editor and assigns this accordingly as well as the name of a sprite, rigidbody, etc. Basically what I have so far is- ...
0
votes
1answer
27 views

Drawing a draggable 2d Cartesian grid in C#

I'm developing a C# WinForms application that will connect (via an API) to a 3D environment. The api provides a means of "querying" the environment and determining the x, y, z location of various 3D ...
5
votes
3answers
196 views

Understanding Scriptable Objects

I am trying to understand the logic and functionality behind Scriptable Objects. I 've watched the provided video 2 times and I keep getting lost. I tried to follow the code as well but with no luck. ...
1
vote
1answer
38 views

Global variables in a multiplayer environment

I would like to know what's the best approach to solve this problem. In a racing game, i need to create the final result chart. In a single environment i've tought something like: private string [] ...
0
votes
0answers
11 views

Script for Sprite Slicing works fine as a MonoBehaviour, but not as a normal class called in a Editor Script

I got a script for auto-slicing sprites from the internet. Link to the script. I made the script so that it is not a MonoBehaviour. Then i do this is my custom assets importer: private void ...
1
vote
1answer
49 views

Increase speed with each enemy destroyed?

I need some help with coding this idea: "For each Target destroyed, increase the Gunner's speed by (speed variable)". The idea is that the Gunner is automatically moving, and I want it to become more ...
0
votes
0answers
141 views

What is the proper way to get input from the motion controllers touch pads?

I've been trying to figure out how to get the inputs from the touch pads on the motion controllers but have yet to find out how to do so. Initially I tried doing the following (as it was how I ...
4
votes
1answer
114 views

Monogame Startup Memory Spike

I am currently porting a game from WP7 using XNA to WP8.1 using MonoGame. I have been putting considerable effort into optimizing my game to be under the 185MB memory limit for low-memory phones. I ...
2
votes
1answer
116 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
2answers
34 views

Script no longer working now that it is attached to a child object. Why is this?

So I decided I wanted to make this script part of a separate swap-able weapon so I made a child and put the script there. Before the script worked fine but now it won't work. The script works as ...
0
votes
1answer
65 views

How can I instantiate in the current rotation in Unity 2d?

Backstory I'm currently working on a 2D sidescroller/platform game as a hobby, and I just started recently. Followed a few tutorials and such I managed to wrote my own code for basic command like ...
0
votes
1answer
213 views

Can't see instantiated UI element

I'm trying to create a level editor for a 2D game and I wanted to instantiate radio buttons, the backgrounds and numbers of which are determined by the tilesheet I load. I'm sure I'm doing something ...
0
votes
1answer
14 views

Finer collision detection with multi-path Polygon2DCollider from Tiled2Unity

I'm in the process of incorporating Tiled2Unity prefabs into my code. Their exporter creates a collision object (shown below) that amalgamates the collider of each tile into a single Polygon Collider ...
-1
votes
0answers
17 views

Unity3D-C# - Resetting WaitForSeconds() on IEnumerator Coroutine

Mmmmm I dunno if I need to show code for this, ´cause this is more of a general question regarding a resetting of a StartCoroutine, or of the yield WaitForSeconds method. Because when I start the ...
0
votes
0answers
11 views

Problem with camera drag and draggable UI elements

I implemented my camera drag using the following method: if (Input.GetMouseButtonDown(0)) { dragging = true; followPlayer = false; oldPos = ...
0
votes
2answers
51 views

Object shrinks at same rate no matter what

I am using the following code to shrink a sprite: public bool shrinking = false; public float targetScale = 0.1f; public float shrinkSpeed = 0.1f; void Update () { if(shrinking) { ...
-1
votes
0answers
18 views

How to throw an object Unity3d platform? This 2D

There is a platform revolving around its own axis (it works). We need to make sure that when you change the angle of the object platform rolled (it works), and the sudden change in the direction of ...
0
votes
1answer
20 views

OnPointerClick not being called

I implemented the IPointerClickHandler in a script that runs on multiple GameObjects in my scene. I'm definitely missing something since the implementation is not being called at all. The objects are ...
0
votes
0answers
29 views

Opentk hdr rendering with framebuffer white screen problem

I am trying to do hdr rendering with two shader programs: one simply draws a hdr texture on a fullscreen quad and the other one does tonemapping. I am trying either linear tonemapping colorOut = ...
0
votes
2answers
29 views

Unity inspector script - making it save the global variables for what it's creating

I have a script which initialises a bunch of child gameObject(s). I wanted all of this to happen outside of the game, so I created an inspector script which has a button which triggers the method ...
0
votes
2answers
79 views

Add singleton to an existing gameobject in Unity via script

I did notice that if I assign scripts that generate singleton classes (for my managers), to an empty game object, everything works fine. Now I would like to start the scene with the empty game ...
3
votes
1answer
59 views

Player motion and combo systems

Where do you usually implement player motion when going through the state machine of a combo system? An example, when player presses X+Y it must do an uppercut like movement (Like street fighter) ...
-1
votes
0answers
14 views

3D Scatter Charts [on hold]

I have been looking at several open-source kits to implement a 3D scatter chart. Currently, leaning towards using Helix WPF toolkit, but my skills are not that strong on the xaml side of things, ...
0
votes
1answer
53 views

Script for non-stop enabling/disabling “Is trigger” on collliders2d in Unity3D?

I had asked before that I have a problem with too many colliders in one spot and that some upgrades of towers I have are buggy due to that. It has come to my notice, that whenever I enable the "Is ...
0
votes
2answers
272 views

How to properly give Image source for multiple sources?

I'm writing a script to change the image on the button based on previous selection. Another script is giving the CurrentAvatar variable once previous button is pressed. My problem is i can't seem to ...
-2
votes
1answer
64 views

How to add DontDestroyOnLoad(); to script?

I am new to game development. I have a script with audio source and one slider to adjust volume of audio. I want to keep my music playing through all scenes. I think I have to use ...
0
votes
1answer
110 views

Unity3D - Using AddRelativeForce to push an object forever in zero gravity environment

Ok, I use AddRelativeForce to basically push an object. But it suppose to keep flying and keep accelerating as I hold down the key because I didn't set gravity. I just started Unity3D last month, so ...
1
vote
2answers
221 views

Help on transition from one position to another

I'm pretty sure I'm over thinking stuff, but I can't seem to figure this out. I want to move the object from one location to another. Here's what I got. I searched this up earlier here, and I found ...
1
vote
1answer
241 views

How to detect collision position and that position's texture color in Unity?

I have a prefab and I use Circlecollider2D for physics operations. I want to detect the color of the contact position of the collided objects ? Is is possible by using Unity's collider classes ?
0
votes
2answers
92 views

Build a vbo once every second

I have a VBO storing some data in my game. The thing is, the data can change at a rate of about a second. The data is not fixed size, meaning that some objects will sometimes be visible, sometimes ...
1
vote
1answer
163 views

What can I do in Unity3D to optimize the way I'm calculating contrast of a texture2D?

I have this contrast script right now in Unity: public void ApplyContrast(string contrast) { try { double contrastD = Convert.ToDouble(contrast); //Make ...
1
vote
1answer
429 views

How can I use a lookup table for brightness and contrast?

Currently, I implemented a rudimentary brightness and contrast algorithm that changes brightness and contrast pixel by pixel. This was super inefficient performance wise and the algorithm looked a bit ...
-1
votes
0answers
23 views

How to read from .json [closed]

I have data in .json file.I am looking for ways to parse it in c#. My json contains data like this, {"howManyToSpawn":1,"positions":[1],"difficulty":0} ...
1
vote
2answers
102 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() ...
2
votes
1answer
24k views

Correct way to use a GameObject.Find method in Unity C#

I have been following along with a Lynda.com video course to familiarize with Unity. I am currently attempting to grab a reference to a scene's First Person Controller's transform as follows: ...
0
votes
2answers
62 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 ...
3
votes
2answers
1k views

How do I deal with abstracting collision handling code between entities with differing collision components?

I'm using a component based entity design with Components that hold the data and Systems that act on entities based on the components they have. Entities are registered to all systems as they are ...
0
votes
1answer
15 views

Unity Android character controll with UI Buttons

So I'm trying to find a good tutorial which will explain how to controll character in 2D game when button is clicked (left, right, jump button). All the tutorials I've found are outdated and not ...
0
votes
1answer
33 views

GameObject eulerangle rotation is off

In a game I am creating players can flip their character. So say the player does a front flip, it triggers an animation that plays to flip the car forward. I have the player as a child of another ...
0
votes
1answer
27 views

Object automatic create new with old every time when load / save game.?

My problem with this DontDestroyOnLoad(cube.gameObject); When I load my player position its create new object with default and saved position respectively. I have a screen shot for better understand. ...
1
vote
1answer
69 views

Unable to move mouse cursor while pressing keyboard button

I've a player to which I've attached character controller and two scripts - Controller and MouseLooker to control the player movements but when I try to move my mouse cursor while pressing keyboard ...
0
votes
1answer
27 views

Covert Minimap render texture to 3d space position

I am using Render texture to make a Mini Map it is working fine but now I want to go further on side map and want world space position from render texture click point. Is there any way available that ...
-1
votes
0answers
32 views

Fade out / fade in scene w/ loading screen [closed]

I've got a (very simple?) requirement I just can't get to work, even though it's been covered by numerous tutorials and how-to's on the web. Basically, I want to transition between individual scenes ...