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
138 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
votes
2answers
84 views

Why doesn't Unity keep keydown states between scenes, and how can I change that?

So basically, when my scene in Unity changes and I'm holding down, say, Right or Left, when the scene resets, my player (and Unity) doesn't even recognize that I'm still holding that button, until I ...
0
votes
1answer
42 views

How can i show all edges in monogame?

I am using Monogame 3.5 and i have simple model of cube. I use BasicEffect to draw it. I want it transparent so i use effect.Alpha = 0.5f. Is it possible to show all edges something like on picture?
0
votes
0answers
38 views

Monogame - tile map with XML instead of JSON

I'm working on the levels for my game so I've built these classes to read my maps: Tiles.cs: protected Texture2D texture; private Rectangle rectangle; public Rectangle Rectangle { get { ...
1
vote
1answer
274 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 ?
1
vote
2answers
288 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 ...
17
votes
2answers
3k views

Player jittering against wall when held down button

So, I'm making a top down RPG. Everything's going excellent, but this problem is quite annoying. Now, when the character moves against the wall, the player jitters back and forth. I'm guessing it's ...
1
vote
1answer
474 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
vote
1answer
79 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
384 views

Unity3d - c# - changing FPSInputController controls through script

For a game I am making I would like the user to be able to change the controls (in game NOT through the clunky launch window (wich i disabled)) I have the system working but don't know how to change ...
0
votes
2answers
47 views

How can I change my script execution order programmatically?

I have a script that I want to run before any other script. I want to change its execution order settings. I could do that using the Script Execution Order Settings option from within Unity, but I ...
4
votes
1answer
793 views

Custom Editor for Map/Dictionary in Unity

I'm trying to build my own little ResourceManager in Unity that will allow me to tag resources (ranging from materials to prefabs) to a label in the editor, and then access them in game. The ...
1
vote
1answer
178 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 ...
0
votes
1answer
37 views

How to set only one collider with OnCollisionEnter(Collision col) in Unity?

I tried with this: void OnCollisionEnter(Collision col) { Debug.Log("hit everything"); if (col.gameObject.layer != LayerMask.NameToLayer("bico")) { if (col.gameObject.tag == "...
4
votes
1answer
152 views

AI using character controller makes unwanted change to it's y position

The enemy parent object does not have any colliders except for the character controller. It starts out with y = .57 and immediately jumps to y=1.6355 because of my call to CharacterController.Move(.) ...
0
votes
2answers
54 views

What Collider should I use for my Player object?

I am making a 3rd person game with a simple orbit cam and it works fine most of the time, but since I have a box collider and I walk across an uneven surface, the player tends to tip over. How should ...
-1
votes
1answer
64 views

Increment int in array - int i is out of scope? [closed]

This is my scenario: I have a 3D model of a house, and an autonomously moving robot moving through the house picking up multiple objects. I have an array of 3 objects I want it to pick up, but I don'...
0
votes
1answer
64 views

Assign a ScriptableObject to MonoScript through code

Sample code: public class Item : MonoBehavior { public ItemObject item; //the scriptable object void Start(){ // do stuff} } Normally I would drag and drop the asset of the ...
5
votes
8answers
3k 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
2answers
36 views

Autonomous robot - moving from 1 object to the next object

This question falls in line with my last question: Unity 3D - create autonomous moving robot in house + first person camera movement What I have I have a 3D model of a house; a first-person camera ...
0
votes
1answer
10 views

Drag event inverts in landscape mode

I am developing an car game for android with an UI steering wheel to control the car. I'm following Answer example for the wheel rotation. This is the code to rotate the wheel. rectT....
1
vote
2answers
121 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
2answers
32 views

Is There a Way To Keep Precision When Transforming GameObjects

I've seen this issue before, but it's never been a particular issue for me until today. I have each "room" of a dungeon created with a class script that contains details of that room. During the ...
0
votes
1answer
32 views

Moving autonomous robot form one location to another based on array

I have a 3D model of a house, and I want an autonomous robot to move from 1 object in this house to the next one. I have it moving to the first, but it won't move to the second one. This is my code: ...
0
votes
1answer
62 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 ...
0
votes
0answers
40 views

How to make an object move in winform application c#?

I'm trying to make an object in such a way as to allow it to move. This is the objects that I initialized. This is a 25 cell board, made with 4 types. Black box is made from number 0, White box is ...
2
votes
2answers
182 views

2D Collision at corners using C# - without xna or unity

I'm trying to make collision for a 2D game, the player (car) has to collide with the walls of the track when it hits them. I looked into pixel color detection, and X,Y -based collision (But since its ...
4
votes
2answers
526 views

Jittery Movement, Uncontrollably Rotating + Front of Sprite?

So I've been looking around to try and figure out how I make my sprite face my mouse. So far the sprite moves to where my mouse is by some vector math. Now I'd like it to rotate and face the mouse as ...
0
votes
3answers
887 views

How would I go about making a movement system like Mario Party?

Main question How would I go about getting a movement system similar to the one they have in Mario Party only minus the dice roll? Things I have researched I have been studying the uses for ****...
0
votes
1answer
48 views

Type `UnityEngine.UI.Text' does not contain a definition for `Text' [closed]

I came from Unreal Engine 4. I created a script, and I keep getting an error: Assets/scripts/UpgradeManager.cs(17,18): error CS1061: Type `UnityEngine.UI.Text' does not contain a definition for `...
1
vote
1answer
46 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
14 views

Resolution-Independent Rendering squishes view field

For the last couple of days, I've been trying to get a resolution-independent renderer going on an XNA game. I have a camera and a renderer class that I added, based on this tutorial Here's the ...
0
votes
2answers
32 views

Lerp velocity in specific time

How to lerp velocity to 0 in specific time? For example in two seconds? I need this for jumping. velocity.Y = MathHelper.Lerp(velocity.Y, 0, [time]);
0
votes
0answers
18 views

Unity 5 New Netorking, SyncVars, RPC how does it actually work

I have just started working on a client - server flow for an open world game, as far as I understand unity have implemented a fairly new ways to communicate and work with networking but I cant seem to ...
3
votes
2answers
38 views

In Unity, is there a way to Set a new MeshRenderer?

Here is what I want to do in Unity for a given GameObject go = new GameObject(). I want to create a MeshRenderer, change its properties and only in the end set it as the component of go. For instance: ...
0
votes
1answer
44 views

Access to varibles in other attached gameobject script is ambiguous

I'm trying to create reusable scripts that I can drop on my GameObjects. I am currently trying to figure out how to build a projectile script. Ideally, I want to be able drop this scrip on an enemy, ...
1
vote
1answer
281 views

Collision detection doesn't register until player sprite jumps

I have implemented a shooting mechanic into my game, and the act of shooting works fine. The shooting work is done in my "game1" class. The issue that arises is when I incorporate collision detection ...
0
votes
0answers
29 views

How to silence the Windows Asterisk sound?

When pressing keys while my game is running, Windows makes the "Asterisk" or "Exclamation" sound that you hear while trying to use the keyboard on a window that doesn't have focus on an input control. ...
0
votes
1answer
61 views

Unity 3D - create autonomous moving robot in house + first person camera movement

I have very, very little knowledge about programming or Unity. I have done some basic tutorials, but I want to try something harder. The thing is, I don't know where to start. If you find the time to ...
0
votes
2answers
116 views

Detect Input.GetMouseButtonUp outside a GameObject in Unity?

How do I detect Input.GetMouseButtonUp outside a specific GameObject's area in Unity? Are there any Unity Assets for this?
0
votes
0answers
12 views

Unity and C# - Lighting concentrated on floor with RenderSettings? How to get even lighting on all objects?

I am just getting into lighting with Unity 3d and right now have a function that progressively deepens the lighting of my scene here. I have done this via Render Settings and have tried 3 different ...
0
votes
1answer
76 views

How to combat exponential growth in sprite messaging?

In my 2D platformer game, I have a number of sprites moving around the world. When two sprites collide with each other, I calculate how deep the collision is and then call a virtual method on both ...
5
votes
1answer
151 views

How do I change a value gradually over time?

I'm using Unity3D 5-point-something, and I'm planning on making a game where the player travels through a hot, dry desert, and so the heat causes the player's energy to deplete. The object of the ...
6
votes
4answers
3k views

Does “Object.ToString().GetHashCode()” return a truly unique character seed?

In my game I'm generating a character seed from a bunch of traits that the player chooses. The traits are all part of a Enum. In unity I've attached a script to a bunch of toggles. When the player ...
0
votes
2answers
69 views

C# XNA :Snake Game, direction problem

I am trying to do a snake game in XNA but I have some little problems... I explain : The Snake has a direction (Enum Type : Haut(=up), Bas(=down), Droite(=right), Gauche(=left)) When the player ...
1
vote
2answers
73 views

How do I implement level generation based on graph grammars?

I'm looking to do some pseudo-random map generation using graph grammars (graph rewriting). However, most of what I can find online on this is purely academic and, while helpful, doesn't have any ...
0
votes
1answer
55 views

Top Down Bullets will not move

I have a top down shooter. The player can move in the primary 4 directions, and follows the mouse for rotation. When I shoot, the bullets never leave the player, they just spawn on top of the player ...
0
votes
1answer
57 views

Quickly Converting RenderTexture to Texture2D in Unity3D

I have a screenshot preview at the end of the game's level. When I am loading the screenshot, it makes the game freeze for a moment. What may I do so there would be no freeze when I am loading that ...
1
vote
2answers
88 views

Get the difference between 2 matrices

Hi I'm using C# and MonoGame, and have the world matrices of 2 objects. I need to get the difference between them, so I can effectively parent the second object onto the first. The aim is to get to a ...
1
vote
1answer
46 views

How to check strings from multiple lines in one input field?

I need help with input fields. I already set the line type to 'Multi_Line NewLine' in inspector, but I have problem with submitting the string. Here's the code: using UnityEngine; using System....