Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [c#]

C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.

0
votes
0answers
17 views

Increase sound tempo in Unity when new player joins in Kinect game

I'm using Unity to create a Windows-build game with Kinect. I have some drum beats, which can either be used as single sound effect or be edited to be a piece of continuous music. I want these drum ...
0
votes
1answer
32 views

How can I change a sprite used for a Unity Tilemap tile at runtime?

I want to change Tile's sprite during runtime, but it doesn't render. ...
0
votes
2answers
54 views

Background music not stopping while game is set to paused

I am implementing pause game functionality in a Unity3D game using the following script ...
1
vote
0answers
36 views

since unity upgrade, OnSceneLoaded not getting called on scene start

I upgraded my unity project to 2018.3.11f. Since that upgrade, the OnSceneLoaded event is not getting called, even though I am registering the event handler. Here'...
0
votes
0answers
28 views

Why do I get a “Value Cannot be Null” error on material.SetTexture?

Probably a really noob question, but: I'm following this tutorial here and, using the code in the tutorial, I'm getting an annoying error: Here's the code in question, the error is referring to line ...
0
votes
1answer
48 views

(Unity) Values set in Start() will be reset?

This is my GameController GameObject in the Inspector (Ignore Suns and Player). Note that ...
1
vote
1answer
38 views

Counter won't add to score

I'm trying to make a rolling ball game. But for some reason, I can't seem to get the counter to actually add to the score. Here's the code: ...
1
vote
2answers
80 views

How can I make a character crouch?

I tried to make a crouch system. In my script I changed .height and .center properties of collider in ...
0
votes
1answer
67 views
0
votes
0answers
24 views

Draw a texture2D at specific coordinates on another Texture2D

I have a ShipTexture and a Sail Texture. I need to draw the sail texture at a specific location on the shipTexture (call it the sailMountPoint) regardless of the location vector associated with the ...
0
votes
1answer
31 views

How to format my code using Unity C# checkstyle?

Is there any possible way to check your code with checkstyles in C# unity?
-1
votes
0answers
18 views

How to create a 'Mission Set' System just like in the game 'Stack'?

I am creating a simple 2D endless game. I want to implement 'mission set' like the ones in the game Stack, Subway Surfers, etc. I searched on Unity forums and YouTube but nothing seems relevant to ...
0
votes
2answers
56 views

c# clearing bitmaps

I have almost solved my problem. I am able to shoot a bullet and hit a bug and it then draws a collision bitmap. but then it redraws a bug, I want to clear the bug bitmap after the collision happens. ...
0
votes
2answers
95 views

Adding a dodge roll. Unity

I'm a newbie here. I need to add a second collider in CharacterController in the separate script with possibility to enabling/disabling them. I tried to find answer how to do it but I find nothing. ...
0
votes
2answers
66 views

Apply transform.Translate to a specified object in the script

In Unity3D, if I place a C # script including transform.Translate on an object "A" in the hierarchy, it animates the translation of this object A. How in C# can I apply that transform.Translate ...
0
votes
1answer
31 views

How to add to a MonoBehavior array from an Editor script in Unity

I've made an editor which makes a list of tags and splits them into two rows of true or false values (selectable by the user). I then compile this list into a dictionary, and each entry is like so: <...
0
votes
1answer
61 views

vertex manipulation in instanced shader hlsl SHARPDX 4.2

[SOLVED] - The project is here https://drive.google.com/open?id=1-kum0phM_iBMc8xRxYShmCNRWRs6W0Aw I am using the same vertex shader and pixel shader for my instances. I am sending ONE FLAT array that ...
0
votes
1answer
29 views

how do i enable and disable objects with a certain tag in c#?

I have a script that is supposed to find every active object with a certain tag and on the push of a button enable and disable it's meshrenderer and collider. but the script only tries to enable and ...
0
votes
1answer
27 views

should my static class be derived from UnityEngine.MonoBehaviour instead?

I am working on creating an object to maintain state of the game, player data, etc. It is static (singleton lifecyle) through the life of my game. I started down the path of a static class, with a ...
1
vote
1answer
53 views

Finding islands from array

Say I have an two dimensional array with values 0 or 1. How would I construct an algorithm (preferably in C#) to work out which ones are separated or islands. The algorithm would transform the left 2d ...
0
votes
3answers
41 views

Sharing Physics in Unity

I'm making a game with an endless mode where you have to dodge asteroids until you eventually die. Since the game could be endless, I wanted to avoid the coordinates issue mentioned here. My player ...
1
vote
1answer
27 views

Unity2d Camara smooth zoom issue

want to know that how mathf.movetowards works, i tried to play around it and have some issues. i want to make the camera moves from player to target places along with zooming upon triggered and vise ...
0
votes
1answer
25 views

Spawn prefabs from list one by one when trigger is touched

I am trying to spawn one gameobject from a list of gameobjects each time I touch the trigger with the controller. But when I do this, all the game objects from the list spawn together at the same ...
0
votes
1answer
25 views

Play games services leaderboard does not work all the time

I am trying to login into play services. I got it working. But there were duplicate game objects created. So I added do not destroy on load and now the play services work the first time I access it. ...
2
votes
2answers
136 views

How to run a long task without freezing my game?

I have a component that is in charge of generating a level at runtime, and this is an operation that takes quite some time. As a consequence, I experience a hang when this operation is executed (when ...
1
vote
1answer
30 views

How to manage server “view” of game board when it is shared by clients?

I'm currently creating a simultaneous turn based card game in which two players play cards in three lanes to determine who wins points in these lanes. I've been struggling this past week trying to ...
2
votes
2answers
150 views

Most efficient way to get the closest point to a 3d rectangle

I have a 3D rectangle, with 4 points (x,y,z) And I have a player, who can be anywere (inside the rectangle, outside, not even in the plane, in the corner...). I would like to get the closest point in ...
0
votes
1answer
41 views

Why the lockState of the doors is all the time false even if in the editor I set one of them to true?

In the DoorsLockManager in the class DoorClass I changed in the editor one of the lockState to true but when running the game they are all change to false including the one I tried to set to true. Not ...
0
votes
1answer
42 views

Play a sound on button click before loading the load scene in Unity3D

I am trying to play the sound of the button click before loading the scene in unity. However, the sound is never played. Below is my code, help would be appreciated. ...
0
votes
2answers
44 views

Sending a shot left/right/up/down based on directional key press

I am trying to make a top-down shooter game with similar combat to the Binding of Isaac: when I press the up key the shot goes up when I press the right key the shot goes to the right I have all ...
0
votes
1answer
31 views

Quaternion.LookRotation with Joystick

I am having an issue i cannot seem to figure out within my code. What this code does at the moment is that it rotates the 3D Model around the z axis but i need it to rotate around the y axis. Any help ...
1
vote
0answers
19 views

Prefab sorting layer wrongly displayed

I have a prefab 'WhiteSmoke' that should render on top of the other objects on my game view but instead it just stays behind. The sorting layer some you see on the image named 'smoke' is the top layer,...
-5
votes
1answer
44 views

How to create “Hexagon” GameObject in unity

So i'm making a mobile 3d game, and i need to have Hexagon gameobject and yeah i searched the whole internet but didn't find any solution (i've tried blender to create hexagon but it didn't work, when ...
3
votes
2answers
111 views

How can I create a random deck of 7 cards every time they are all used?

I'm trying to create a Tetris like game in C# (Unity) and I've run into quite a problem on how I can generate 7 cards (tetrominoes) of which none are the same and when I run out of cards, I regenerate ...
0
votes
1answer
17 views

Unity Canvas hover image does not trigger event

So i have the following setup: This produces the following UI: Now on each of the "HudCircle"(Bottom/Right/Left/Top), I have the following components: As you can see I have a script that has the ...
0
votes
1answer
19 views

Getting the same message while using Facepunch.Steamworks

I use Facepunch.Steamworks for P2P game made in Unity, so I send packets through it(UnreliableNoDelay sendtype), but I've got a problem, since I send message like this: Move:0 and get this: Move:00,...
0
votes
0answers
14 views

Can't refer mesh size after using .BakeMesh() in Unity

I can't figure out how to refer to the size of a particular mesh. The mesh is created through .BakeMesh(), then a box collider is added. Unfortunately the box ...
1
vote
0answers
26 views

Seaming between procedurally generated terrain meshes in Unity

I have been generating procedural terrain for an upcoming project however I am coming across a seaming effect between the tiles: I have searched for solutions including this video. Here is the code (...
1
vote
1answer
33 views

2D Circular Distribution Overlap

I'm working with the C# wrapper for SDL and am stumped at how to handle this issue. Right now I have a simple Actor that spawns N number of bullets from himself and fires them circularly outward. The ...
0
votes
1answer
60 views

Changing the camera in Unity

I am trying to make a game like Mario Party in Unity. I want the camera to automatically change between players after each turn. I don't have a lot of experience in C#, and I totally would learn ...
0
votes
1answer
49 views

Smoothen line on linerender

I've created a square using linerenderer but my problem now is that the line is not smooth. see below picture. I've tried enabling anti-aliasing and setting lr.numCapVertices to no avail. ...
0
votes
1answer
44 views

Unity - Play animation based on horizontal drag position

So, what i want to do is some what complected, but I'll try to explain it to the best of my ability. I am using Unity's EventSystems events to detect a drag. When the user drags the object ...
1
vote
1answer
66 views

How can I reference C# objects in GDScript (and vice versa)?

I am using Godot Engine 3.0.6 Mono for Windows x64. I am prototyping the majority of my project in C# before I rewrite the game in C++ for release. I installed this plugin mostly to help with testing ...
0
votes
0answers
36 views

How can I change the parameters of the random events for each game entity?

I'm trying to write an easy-to-use random event system that has certain conditions and effects in Unity. It's a simulation game that contains multiple Person, City, Country, Faction elements. I have ...
0
votes
0answers
13 views

Using Azure with Unity

I currently use Unity 2018.3.9f1. I would like to hook up my Unity program to an Azure service, so that I can store/analyse information about user behaviour. As a primer, I tried to import the ...
0
votes
0answers
40 views

How does Unity store references to GameObjects in a scene

A Monobehaviour can have references to GameObjects in the same scene, but Prefabs, ScriptableObjects can't reference GameObjects in a scene. While Assets, Objects and serialization covers references ...
0
votes
1answer
56 views

How can I draw a rectangle with a color gradient?

I'm trying to implement below picture in my code but doesn't work. It only shows red color on all sides. I'm using line renderer and color gradient. Kindly check my code. Thanks in advanced ...
0
votes
0answers
31 views

How to update model transform of components when using physics?

I implemented a high level components system for my renderer and am curious about the right way to update the transforms components of models that have a physics rigidbody attached. I am using ...
0
votes
0answers
14 views

Scripting | Logic/Workflow problems

Im trying to make a Character controller, but I have some problems. I have a principal script where is the movement with velocity, and the jump, also there is a bool for when he can move or not. The ...