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

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
2answers
28 views

Foreach/list loop problem

i am having a problem with a foreach loop. When my AOE ability hits an enemy it creates a CircleCollider2D and puts all enemies on a list, which then the loop goes trough and adds damage to their ...
0
votes
0answers
9 views

Spawning player at a certain point after a new scene was loaded

I have a Game Manager with a DontDestroyOnLoad function on it, before loading a scene I'm passing the variables needed to reset players position to a certain position. This is what my code looks like; ...
0
votes
0answers
17 views

c# hex grid screen

I am able to draw a single hex to the screen. I want to draw a whole screen of hexes. Here is my code so far. ...
0
votes
0answers
8 views

Unity - adding camera contraint to prevent the player from seeing beyond the scene

Like the title says, I'm after some kind of constraint for the camera to prevent the player from seeing beyond the scene and seeing the Skybox. I came across the code to add a Mathf.Clamp, but I can't ...
0
votes
1answer
8 views

Unity - IsTouchingLayers problem

I'm experimenting with 2d physics, and the problem is this: The IsTouchingLayers function reveals that the object is touching a layer, but only if I use the...
-1
votes
0answers
17 views

Creating objects in one for loop and destroying them in another [on hold]

I need to dynamically create some objects in a for loop. After they've been created, I need to destroy some of these obects in a second ...
0
votes
2answers
22 views

How to detect whether a transform has rotated left or right

I have a game object in my scene, and I want to know how can I calculate whether this game object rotating to the right or to the left. For example : ...
0
votes
0answers
13 views

object reference not set to an instance of an object [duplicate]

hello i have a error "object reference not set to an instance of an object" when my ball collide with the spikes.its supose to remove one heart but it doesnt. health code: ...
0
votes
0answers
22 views

3d characters on 2d background game suggestions [on hold]

First off, I am wanting to get back into making games, I have made a few for personal use in gamemaker but never finished them as school always got in the way or they would get deleted when my ...
0
votes
1answer
16 views

Unity - rotating character for 2.5D platformer

I'm currently making a prototype for a college project in Unity. The game is a 2.5D platformer, though I've incorporated a script for the camera from a 2D platformer so the camera moves ahead of the ...
0
votes
3answers
50 views
0
votes
0answers
9 views

Joystick Orientation Wrong After Camera Rotation

I am using a virtual joystick to move & rotate the player and a touch swipe system for the camera rotation, The problem is that when I rotate the camera (Let's say I rotated the camera to 45 ...
0
votes
0answers
7 views

Stop audio in all scenes using a slider in the main menu

I am using different sounds in different scenes, but problem is that I can't stop all sounds using slider in the menu. It stops only the menu sounds, or sounds for the current scene. When my game ...
0
votes
0answers
10 views

Instantiating tiles

I'm writing a game that instantiates a large gameBoard. For some reason the below code won't instantiate tiles across the Y-axis. All 10000 tiles are instantiated in a straight line across the X, and ...
0
votes
0answers
9 views

Move & Jump Character in Unity (Book “Unity in action” 1st edition)

I, according to the book Unity in Action, studied Chapter 7, I don’t know whether I’m doing something wrong or a bug in the book. In general, the Character Controller clings to objects and it turns ...
0
votes
0answers
21 views

Which “using” directive am I missing? [on hold]

Habitually, I write at the beginning of my C# scripts: using System.Collections; using System.Collections.Generic; using UnityEngine; When I write: ...
0
votes
1answer
19 views

How to check if a specific instance of a prefab is pressed?

This one is hard to explain, so I'll show the code first - ...
1
vote
1answer
37 views

How to stop my cube collider when it hits another collider using Transform.Translate?

As we know, Transform.Translate() ignores collisions. What functionality do I need to add to my code so that when my collider hits something, the physics system ...
0
votes
0answers
16 views

Game Development using Unity [on hold]

I know how to code in C#, now I want to start game development using unity, but I never used Unity before. What must be the first step for getting started in Unity? And what are the other things that ...
0
votes
1answer
21 views

Moving a dynamically spawned object

I would like to create an object dynamically when the player presses Q and use this object in Instantiate and in ...
0
votes
1answer
35 views

Character rotation according to camera causes rapid flipping when game starts

When I load my scene, my character rotates +90 and -90 on the X axis very fast about 4 or 5 times, and then he stops at -90 on X axis (lays back down). When I move the character, the rotations are ...
0
votes
0answers
19 views

NullReferenceException: Object reference not set to an instance of an object on boolean variable from separate class [duplicate]

I'm trying to develop game scenario that able to trigger the alarm with alarm light and siren audio to play. For the testing purpose I set it that to boolean value as "alarmOn" in AlarmLight class. <...
0
votes
2answers
49 views

Make a platform appear and disappear constantly

I am building a platformer. In this game, I need one of my platforms to constantly activate and deactivate. Here is how I have tried to code this so far, but it causes Unity to freeze: ...
1
vote
1answer
28 views

Why does my Unity C# List not load from FromJSON()?

I'm using Unity and trying to load in data from JSON files. It finds the files, but no data comes through. when I do a Debug.Log(count) on it it tells me there are zero entries. But the same code for ...
0
votes
1answer
45 views

How to stop Objects with Rigidbodies from explosion when dragging

I have a sequence of capsules linked with fixed join and each capsule have a Rigidbody and a cube collider (the picture bellow shows how it's look like) and this ...
0
votes
0answers
19 views

I want to be able to branch a path based on choice

I'm making a 3D game in Unity in the style of a board game. I'm still very new to C# and this prototype of a game is to let me enter the college I want to go to. The foundation of my code is based on ...
-1
votes
0answers
30 views

C# How to Prevent Accidentally Editing Backing Store of a Property [closed]

In C#, is there a way to not accidentally edit the backing store instead of the property? (Assuming they are in the same class)
0
votes
0answers
16 views

How to access a Texture inside of a Vertex Shader. SharpDX 4.2

This is a continuation of the question found here: vertex manipulation in instanced shader hlsl SHARPDX 4.2 Now that I was able to modify the positions of the vertex in a Vertex Shader through ...
0
votes
1answer
35 views

How to make a rigidbody come to rest faster

I'm trying to move around a 3D rigidbody in Unity 2018.1.0f2 Personal. I am using a C# script with the basic vector3 and velocity stuff from a YouTube video: ...
0
votes
0answers
24 views

Accessing a char array from another class

I'm working on a crossword puzzle game. In order to set the letters in my tiles, I have a script attached to text components that accessing a char array that stores my letters. It looks like this: ...
0
votes
1answer
23 views

Cursor issue in Unity

Main question: How can I make this possible so that I can press a UI button inside the canvas while the cursor is locked? Hello, I am creating a 3D video game. I have fully functional character ...
0
votes
1answer
23 views
0
votes
2answers
65 views

How to make a character that moves like a slinky?

I have a school assignment to make a 2D platformer game, with a character that moves like a slinky: (Animated example from the assignment linked above) At first, the character needs to grow in ...
0
votes
1answer
32 views

how to duplicate a button via script?

I have the following code: ...
0
votes
1answer
67 views

Start a progress bar when clicking a button

This is basically what i am trying to do: Click first scene->Button Start A Progress Bar When the Progress Bar finishes, then... Second Scene->instantiate my Game object This is my code: ...
0
votes
2answers
65 views

Unity is single thread then why unity webgl says asset bundles are load in main thread

I am get stuck in a performance issue in unity Webgl that whenever my asset bundles are load the unity game get freez for some seconds/mins. I know that unity is not thread safe and it is based on ...
0
votes
0answers
32 views

How can I load back from a text file the values to the variables?

I'm using a simple text file to write to using StreamWriter but maybe it's better to use a json. For example how I used the json before: ...
-1
votes
1answer
33 views

How can I change the direction of movement each time a key is pressed?

I would like change randomly the movement of an object every time I press Q. It seems like the code should be like this, but it does not change the direction of movement as expected: ...
0
votes
0answers
46 views

Cyclist detecting player

I'm working on a game and I have a my player with the tag "Player". I have a cyclist spawning system, and each cyclist has the tag "cyclist", they are all prefabs. I have a script on the cyclists ...
1
vote
1answer
36 views

issues about combo attack system animation

i have some issues about my attack animations right now, i'm doing my light attack which has 3 separate attacks and animations. the scripting and trigger works(without animation), but my animation ...
0
votes
1answer
25 views

Attaching a swinging object to a rolling object?

I am new to Unity and attempting to create a platform that hangs down under a roller that runs on rails. I've gathered my objects and come so far but I can't for the life of me work out how to attach ...
1
vote
2answers
86 views

How can I sync billiard balls in network?

I'm developing a billiard game my problem is I don't know how can I sync balls in network I use forge for networking but feel free to answer photon or unet because I know them. What I tried 1....
2
votes
2answers
66 views

Is it feasible to create a game in godot using little to no GDScript [closed]

I am trying to get more into game development, I have very little experience with it. I've been messing around a bit with the Godot engine and am slowly starting to understand it more. I have some ...
0
votes
0answers
18 views

“Namespace cannot directly contain members” error

Here is my code that could not be compiled because of this: in the first line of this code is indicated: a namespace can not directly contain members such as fields or methods ...
0
votes
2answers
31 views

WaitForSeconds error

I'm new to c# and coding, sorry if I sound like a noob... I don't know how to fix the waitforseconds error, and I don't know what's wrong. ...
0
votes
1answer
42 views

My Unity project does communicate with MongoDB on the Editor but not on compiled build

I was trying to implement MongoDB with my Unity WebGL and everything is working fine so that I managed to insert and retrieve documents from my mongo database with no issues, so everything was perfect ...
1
vote
1answer
561 views

How do I implement bullet spread in three-dimensional space?

How can I shoot a bullet in three-dimensional space in such a way that its path diverges a bit, randomly, from the direction in which the gun is pointed? I know I have to use the Quaternions, but I ...
1
vote
2answers
61 views

OnMouseDown() execute only once

I have the following OnMouseDown() function: ...
0
votes
1answer
30 views

Public variable changed in script isn't stored in playmode

I have a public variable float x in script Foo.cs. I have a Bar.cs script with a function ...