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
votes
0answers
41 views

Using a Singleton for an EditorWindow

I am trying to create my custom EditorWindow in Unity, using a Singleton structure for logic between Editor scripts What is the proper way of creating Singleton in EditorWindow structure? Maybe ...
5
votes
1answer
253 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
26 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
68 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
33 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
48 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
36 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
29 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
48 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
19 views

Problem with resizing SDL2 Window in C#

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

OpenGL Texture from Raw Data Not Rendering Correctly

Starting off the class in question is here: ...
1
vote
2answers
54 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
35 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
31 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
15 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
132 views

c# tic tac toe computer player

...
0
votes
1answer
9 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
75 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
48 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
28 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
13 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
61 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
25 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
13 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 ...
-1
votes
1answer
40 views

Sonic 3 Bonus Stage - Technique Discussion

This will be my first discussion on the gamedev stack exchange, so thanks for reading. My question pertains specifically to the special/bonus stages in Sonic 3 where the game gives you a convincing ...
0
votes
1answer
25 views

Better way to handle speed able time and action in unity

I have came across a problem where i have to do some time based task(simulation) like, As the game started: After 2 mintues launch a missle. After 4 mintues star a train on track after 12 minutes ...
0
votes
0answers
53 views

How do I slice a 3D object at runtime in Unity?

I'm specifically looking for some sort of algorithm or way that can "cut" a 3 dimensional mesh with some other game object. How would I implement this?
-1
votes
0answers
25 views

Strange “Object Reference not set” error [duplicate]

I have been working on an RPG for quite a while and found a silly mistake: the C# script that handles defense calculation when hit, "Player_Script", doesn't get the actual defense value from the "...
0
votes
0answers
31 views

Set the Number of Levels at Runtime

Could anyone suggest a way that I can allow a user to set the number of levels that will be in a Unity3d game at runtime, and load them accordingly? The level design information is held in text ...
0
votes
1answer
56 views

C# 2D Perlin Noise Heightmap By Seed

I need a function of 'Perlin Noise' in this format: public int PerlinNoise_maxY(int seed, int x, int z) { // ... } The function gets Seed, X cordinent and a ...
0
votes
1answer
45 views

Object coming from far away effect in 2D

I have a path made using segments of sine wave interpolation put together that is drawn flat on the screen. And I would like to give the path the effect of coming towards the player. I tried to draw ...
0
votes
1answer
31 views

How can the ball moving like billiard after collision with wall?

I tried ball.velocity = Vector3.forward * speed and also *=-1 when the collision is occurred(It only works for straight way. But I want the ball movement be liked in photo. How can i do it? Thank you ...
0
votes
0answers
21 views

Fail to Start android service in android studio Unity

I have written a service file in android studio like: Manifest file: ...
0
votes
0answers
28 views

SDL2-CS and Gtk Sharp like SDL2-CS and WinForms in C#

who knows SDL2-CS embeds in Gtk Sharp 2/3? Similar example by Ethan Lee with Winforms But I really want know how do I fix with SDL2-CS in Gtk Sharp because I am working under Ubuntu 18.04 SDLWidget....
1
vote
2answers
46 views

Detect Collisions While Dragging 3D Game Object

Hello i am making a game in which i have to drag a sphere on x axis and z axis on a plane with my mouse and i have created walls from cubes so that my sphere not go anywhere else in the game but while ...
0
votes
1answer
54 views

Why does the drag fail when I move too fast?

I got this code that drags a 2d sphere when i touch the screen: ...
0
votes
1answer
38 views

XNA 4.0 How to combine triangles vertices 3D

Preview for the problem: I'm making a similar game to Minecraft (a game that it's world is made by cubes), but the fps of the game is getting low only by rendering a little amount of cubes in the ...
1
vote
1answer
35 views

Camera to the right from the character

I'm trying to create a camera like in Fortnite or Gears of War. It's focus must be to the right side from the character: But when I rotate the camera, the character slightly shivers. Lerping and ...
0
votes
0answers
54 views

WHY !! CountDown not Working inside the IF Condition? [duplicate]

i need a way to make the countdown decreasing inside the if statement i am stacking in this problem for more than 3 days .. Don't suggest to me Coroutine cause it will not working in my case cause i ...
1
vote
0answers
18 views

XNA - How to scale sizes and speeds for a minimap?

I'm recreating the arcade game StarGate, and I need to create a minimap. But I'm having problems scaling the minimap textures to fit in the radar box, and ontop of that, making sure the speed of the ...
0
votes
1answer
37 views

SerializedProperty to UnityEvent in a Custom Editor

I am making a Custom Editor for a type that includes a UnityEvent property. I'm currently facing an issue in converting a SerializedProperty to get that UnityEvent. Here is how I declare the event ...
0
votes
0answers
30 views

Android studio background GPS service call and Unity

If I have a service file written like this in android studio: Manifest file: ...
0
votes
0answers
39 views

In Unity, my joystick button only works a few times, why?

My part of the input code looks like this: ...
0
votes
0answers
6 views

Unit Getcomponent error for bookmarks functionality in my game im using playerprefs

this is my bookmark functionality. ...
0
votes
1answer
19 views

Touching screen not working for move object or print message

It's simple, i want to move an object when i touch the screen, but code's not working, i tried to just put a console printing on it, but nothing happens: ...
0
votes
0answers
36 views

Why does my character's collider only jumps with the animation while walking?

My character's collider only jumps with the animation while walking. And when he runs he gets stuck in the air and can walk in the air. Here's my script for jumping. At this point I have tried ...
0
votes
1answer
42 views
0
votes
0answers
14 views

Check if client is owner of object

I am creating simple multiplayer game. I am familiar and know everything about sending messages client > server and server < client but now i came upon one question. How to check if object (in my ...