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.

1
vote
0answers
22 views

How can I solve the “Unable to find back camera” error?

I'm trying to run a script that will display video from my webcam on my computer, but when I run it the error unable to find back camera pops up. My webcam is ...
0
votes
1answer
27 views

Move camera around player while facing player

My player has the following hierarchy: Hero (GameObject) Model (child of "Hero", centered at 0-0-0) Camera (child of "Hero") The camera should be ...
0
votes
1answer
46 views

How is this rotation done?

There is a video here that shows how the camera rotates around Leon. The camera rotates around Leon in a circle, this is not difficult, but I don't understand the timing logic. Once given a short ...
0
votes
0answers
28 views

How to stop Unity Camera from operating when UI Canvas is active

I've got a camera which uses the locomotion asset from the store and follows the camera. I've made a UI with buttons on it which I wish to click but the camera is locked to the center, when I press ...
0
votes
0answers
8 views

Controls don't work when parent or target moves

I have a platform for catching a ball. Platform physics material has bounciness value of 2 which pushes ball twice high from compared to its original position. Camera and platform have scripts ...
0
votes
1answer
35 views

Unet Syncing within AR Hololens

I am out of options. I have tried everything I could and no matter what I do, the Transforms don't sync up. I have had multiple solutions that worked in my test, non AR project, but once I put on the ...
0
votes
2answers
76 views

c# console based snake game

...
0
votes
1answer
40 views

Direct3D & Assimp Texture is inverted weirdly!

I'm working on a rendering engine but even on the first mesh is something wrong. I use assimp for mesh importing! In the Assimp Viewer it looks correct: And in my software it looks like this: Look ...
1
vote
0answers
33 views

Particle systems don't start unless I look at them (Unity)

I'm currently working on an atmospheric system in Unity (day/night cycle, weather). I'm having an issue where my rain/snow particle systems won't start unless I look at them. They're way up in the sky,...
0
votes
2answers
84 views

How do I get an NPC to follow the player(and stop when it gets within range)

I'm making a game where you have a friend follow you. I have a script that partly works, but when the friend exits the trigger, it won't follow the player. How do I get the friend to follow the ...
0
votes
1answer
56 views

Stop movement if transform.position.y == 0

Why does the following code not step the object's movement when its y coordinate reaches zero? ...
0
votes
1answer
42 views

Transform inputs don't work

I'm writing a C# player script for a class and when I run, the sound inputs work fine, but the movement inputs don't respond, and I don't know how to fix it. Code: ...
1
vote
2answers
126 views

Why are my waves not spawning as expected?

Hey guys so here's an outline of my problem using a basic 3-step approach The Problem Defined Waves 1-22 should spawn in order with the correct paths and enemy prefabs. However, Waves 1-4 only spawn ...
1
vote
1answer
39 views

how do I set an int to the scroll wheel data in unity

i need to set an int to data from the scroll wheel so I can have the script use this int to display an item attached to a number from that int. i'm using c# i set up my scroll wheel input, what am i ...
1
vote
0answers
25 views

Discrete line inside a 3D matrix

First of all a little premise: I'm following this tutorial on YouTube for procedural 2d cave generation in unity using cellular automata and I'm extending it in order to make caves in all three ...
0
votes
1answer
164 views

c# snake game project

I am making a snake game. I have got it to animate. I just want it to follow the mouse pointer. I am able to find the mouse cursor position. I am also to get my snake to move to the right. What I want ...
0
votes
1answer
47 views

Visual Studio can't handle my unity scripts

I have created a new project in Unity 2018.3.4f1 with Visual Studio Community 2017. I can't edit scripts properly in Visual Studio because of a bunch of errors related to .net framework. How can I fix ...
1
vote
1answer
61 views

Create context menu in Scene view

I created some MenuItemfunctions for navigating, which are currently displayed on the menu toolbar. The C# code: ...
1
vote
2answers
83 views

Recursively calculate possible pathway on a grid depending on max walk distance

I have a character that is placed on a grid. It has a variable maximum walking distance. Grid fields can be walkable or not walkable. As the character may has to walk around certain not walkable ...
2
votes
1answer
60 views

How can I change view to orthographic using a menu?

I'm writing the custom menu using MenuItem and I'm stuck trying to make scene view orthographic when 5 is pressed. What is the ...
1
vote
2answers
105 views

How to achieve a stable hover in Unity

In the game that I am currently making the play character is supposed to hover off the ground. I had used the code from the Hover Car tutorial on the unity website however this causes a lot of ...
0
votes
1answer
147 views

Unity websockets client disconnects after server emits with data

I am using some unity "socket-io" plugin i found on the asset store. (its essentially just a scoket.io wrapper for websocket-sharp) everything works absolutely fine, i can catch clients connecting or ...
0
votes
1answer
68 views
0
votes
1answer
84 views

Manage massive items game data in an Android Idle Game

I'm working on an Android Idle game, with many items that user can buy in each level, that each of them has more than 50 levels who can be updated by the user. Each item in each specific level can ...
2
votes
1answer
102 views

Cannot assign values to variables (?)

I wouldn't say i'm new to unity or programming in general.. but right now i feel so stupid. I have a simple enemy script. I instantiate object with another script, calling SettingUpCreep and giving ...
5
votes
1answer
325 views

How to Implement a Very Simple Game State Manager in Unity?

I’ve tried a bunch of different implementations, and trawled everything online I could get my hands on. Everything has downsides, nothing plays nicely with how Unity wants you to work. Let’s keep it ...
1
vote
1answer
28 views

Tell Unity to use a certain LayerMask to raise or not OnDrop (for a class that implements IDropHandler)

I am trying to make a draggable GameObject that can be dropped within a container but when i'm releasing the mouse button even though the mouse is over the container (and the dragged object too) ...
2
votes
1answer
84 views

How to detect when the mouse is over a particular enemy collider, without falsely selecting bullet colliders?

I have an enemy shooting around. My game mechanic involves hovering over the enemy with the mouse to drain its health. While the enemy is moving, you need to follow it with your mouse. If you don't ...
0
votes
0answers
63 views

How to zoom image on Unity UI to particular point where mouse cursor is located?

I have some RectTransform on Unity UI. I have already implemented some Zoom functionality but now I need it to zoom to the area where the mouse cursor is located. Currently, it zooms to the anchor ...
1
vote
1answer
49 views

Affecting all instances of a GameObject at once

I want all instances of a prefab to change their velocity when one of them is clicked, and I think having each object constantly check a variable with a coroutine might not be the best solution. How ...
0
votes
1answer
40 views

How would I prevent parts of my player model from displaying on the camera?

The "legs" of my playermodel are shown when looking down. I'm using the Unity First Person Controller template. Character when in Scene view: Character when looking down in Play mode:
0
votes
0answers
22 views

Optimal way to select a random item from a list based on its chance to appear in Unity [duplicate]

I am creating a random object spawning script in Unity with c#, and am wondering what the ideal way to do this task would be. So I have a list of 31 objects or so, of my special class type. Each one ...
0
votes
1answer
70 views

Help with 3D Double Jumping in Unity

I'm having some trouble with vertical movement. I'm trying to add double-jumping but none of the scenarios online seem to be working, and I can only ever manage to get a single jump. Here's my code: <...
0
votes
1answer
52 views

How do I spawn trees so that they stick out perpendicular to a 3D planet?

I have a 3D tree that I want to clone so that it is perpendicular to a planet gameobject, so it looks upright when spawned. I tried by copying down all desired rotations of the tree and adding them ...
0
votes
0answers
28 views

Problem with resizing SDL2 Window in C#

how do I resize SDL2 Window correctly? ...
1
vote
1answer
43 views

OpenGL Texture from Raw Data Not Rendering Correctly

Starting off the class in question is here: ...
1
vote
2answers
59 views

Why when adding audio foot steps to the character using animation events only one foot play the sound?

The animation in the Animator is HumanoidWalk In the inspector of the animation in the Animation tab at the bottom I clicked on the Events clicked to add event names the function as Step and moved the ...
0
votes
0answers
52 views

Simple Text Drawing OpenGL ES 2 .Net Core

As the title suggests I would like a simple way to render reasonable amounts of text (20-30 lines @60fps) to the screen in opengl ES 2.0 under .Net Core 2.1. I have tried many libraries however I can'...
0
votes
2answers
86 views

How to convert RotateAround speed to directional speed in Unity?

I am currently using transform.RotateAround(transform.position, Vector3.forward, degreesPerSecond * Time.deltaTime) to make an object rotate around another ...
0
votes
1answer
17 views

Transfer mouse movements to a GameObject in 3D according to camera position and rotation

I'd like the game object to follow the mouse but I have trouble doing this when the object is in 3D and the camera has been rotated. The only thing that seems to be true (and still it works only when ...
0
votes
3answers
161 views

c# tic tac toe computer player

...
0
votes
1answer
11 views

IndexOutOfRangeException on array of transform prefabs in Unity

I have a public array of length 9 containing prefabs I'm using as position references for a moving object. The start function finds the transform.position of the appropriate transform in the array and ...
2
votes
1answer
128 views

C# Improve performance when looping and comparing values on Dictionaries?

On my quest to creating 0 garbage when procedurally generating points I've stumbled upon a performance issue when comparing values to another values stored inside Dictionaries. Initially I used ...
-1
votes
1answer
57 views

Rotation Problem in Mario galaxy like controller [duplicate]

i'm doing a Mario galaxy like CCC. And I have a serious rotation problem, may be Gimble lock, or maybe not. So first, I have a parent object ("PLAYER") who can rotate toward a planet: https://youtu....
0
votes
1answer
48 views

Unity smooth local rotation around one Axis, oriented toward a target

I want to acheive the same rotation you see in the inspector. In short: a smooth local Y rotation, toward a target I have a Vector3 orientation: ...
0
votes
0answers
23 views

How simulate day/night transition on 2d game? [duplicate]

I'm trying to create a 2d game and I want to have a day/night transition, but i'm actually new on Unity and I don't know how to do it, I'm using this code, but give me error and I really don't even ...
0
votes
1answer
20 views

Unity3D short joystick controller script acting weird

So basically there's a joystick and when the user pull the joystick up the controller moves the player forward, to the sides and backward and it's all good. the problem I'm having for example is when ...
0
votes
1answer
75 views

The character does not stand still on the moving platform

I'm trying to create a simple platforming game. I have an animated platform moving in 2 opposite directions. I use this simple code to make the character move along with the platform while he is ...
0
votes
1answer
53 views

Black screen after running emulation mode in the Unity Editor for hololens

I am having issues with black screen when running the emulation mode or simulator for Microsoft hololens. In the preview the camera shows what the user should see. I see no obvious reason to behave ...
0
votes
0answers
14 views

Joint chain not moving as intended

I am trying to create a string for an instrument, such as the strings used in a guitar. For that I created a cylinder and rigged it with 50 joints in Maya. In Unity, the joints are parented one after ...