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
1answer
18 views

Animation Length to Integer

‏‏‎ Currently, I have a script; more specifically for weapons. It handles animations, and the animations are being played and then stopped (once they're finished) by co-routines. I have variables ...
1
vote
2answers
153 views

How to make a Blend-Effect like yomawari did?

I would like to know, how to make that effect, I have seen in the game named Yomawari. The little girl has a lamp and its cone revals the dark spirits around her. But only if they are in the light. I ...
0
votes
1answer
50 views

Remove hidden values within string

I tried removing the Unicode Whitespaces in the string using words[len].Trim() but still there's still an extra character. Every letter represents the coordinate ...
0
votes
1answer
20 views

Contracting Unity EditorWindow UI

How can I make scalable(contracting) EditorWindow UI(not in-game UI) like in inspector example?
0
votes
1answer
99 views

Help me adjust this RPG logarithmic leveling formula! [duplicate]

I'm trying to find a formula that's fits the way I want my player to gain experience and level up. I know this is primarily opinion based but I hope someone can help me! I've used the following ...
0
votes
1answer
49 views

Preventing overlap in OnCollisionEnter2D

So I have successfully built a script that can determine the physics for a ball reflecting linearly off of walls, similar to pong, while the ball is using a kinematic rigidbody. The issue is when the ...
0
votes
0answers
34 views

How can I instantiate objects with gaps between all objects?

When instantiate each a new object I want it to be with the same gaps from also the other instantiated objects. ...
0
votes
1answer
94 views

Using Reflection to access an array from a ScriptableObject in Unity

I am trying to get access to a set of stored variables inside a scriptible object in Unity. This class (SectorDeclaration) has a method to pull a variable with a string of the variables name from it: ...
0
votes
1answer
29 views

Typical Point Light Flow?

A Quick Note This question assumes you have some knowledge about the overall rendering process and do not need clarification on rendering objects with HLSL and a <...
-1
votes
2answers
47 views

How can I change member variable when it's passed as an argument to a method?

I am trying to use the unitConverter method below to change the values of u1_1SCost and ...
0
votes
1answer
42 views

Top down off-screen indicator, Unity3D C#

I'm working on a top-down 3D game where things spawn off camera. Movement only occurs on 2 axis (x and z). Rotation is about y axis. The player is in the center of the camera and needs to have ...
0
votes
0answers
46 views

How to use loops in Unity Job System

I want to calculate the distance between the list of game objects So element will check its distance with every other element and so on, I am doing this with following code it works but not efficient ...
1
vote
1answer
34 views

How can I detect when the formations of units are broken? - Unity 2018.2.x

Sorry if I don't write this properly, this is my first post here. I am working in Unity 2018.2.xx I have an issue where the current solution for checking whether a squad formation is broken. For ease ...
1
vote
1answer
69 views

How to create temp folder to store a file from external directory and use it in a game

I would like to copy a 3D model from external library and save it in temp/Resources/StreamingAssets folder to instantiate an object in unity scene. ` ...
0
votes
1answer
29 views

How can I set AnimationCurve by script?

In the top of the script: public AnimationCurve curve; Then the object in the editor have AnimationCurve but without any curve yet: I want to set one of the ...
2
votes
1answer
54 views

Piece of code causes game to freeze, then keep playing after sometime

Games Basic Premise Ball rolls along procedurally generated path. Click to changer directions. Don't fall off. I have a script dedicated to the path. The path is made up of 20 cubes, along the x+ and ...
0
votes
1answer
148 views

Unity3D C# Drag object smoothly on it's x axis that's already bouncing

In my scene, I have a bouncing ball that collides with a cube. On each collision the ball returns to the same height. How can I get the ball to smoothly move along the x-axis by dragging my finger ...
0
votes
2answers
67 views

The second double jump animation doesn't finish before the player touches the ground

I have an issue with double jump for the player my code is working but I want the second double jump animation finish(idle Animation: anim.SetBool("Jump", false)] before he touches the ground can ...
0
votes
1answer
37 views

How can I move objects in a cyclic loop?

I have number of objects I want to move them up and forward then when the last one each time in the array get to the end position move this object to the start of the array and to the start position ...
0
votes
1answer
35 views

Extrude only vertices where the assigned texture is transparent?

I am looking at implementing a water surface on my spherical object and have created a texture with transparent pixels where the water should be. However, I am currently confused on how I can extrude ...
2
votes
1answer
228 views

Random Range Without Duplicates

I have an array of gameobjects (some questions) if player hit some triggers a question from the array is displayed randomly, I want to avoid duplication of displaying questions. ...
1
vote
0answers
33 views

Avoid object from bouncing non-stop after AddForce() is applied to it

I want to implement some sort of elastic field on my light blue magnetic field when a cylinder is colliding it, it worked except the lines won't stop bouncing. I am enabling the trigger collider on ...
0
votes
1answer
22 views

How to Fetch a Frame Number from Animation Clip

I'm trying to find out how to fetch the frame number from an animation clip accurately. I don't want to get a value between 0 and 1 that shows as a percentage-as-a-decimal how much of the animation ...
0
votes
1answer
141 views

How can I achieve a similar day/night cycle of the sky, but in a 2D game?

I'm currently working on a 2D game, and I was wondering if anyone around here has experience/tips in achieving this sort of day/night transition of the sky? I've done some reading, and some people do ...
0
votes
1answer
33 views

How to remove a scene after the another one has loaded

]2[]3I'm having this problem in Unity where I load a new scene, but the original is still overlapping it. How would you remove the original scene?
0
votes
1answer
44 views

Unity - OnTriggerEnter & OnTriggerExit strange behavior

I am having a trouble with OnTriggerEnter with a lot of objects. I have a NavMeshAgent moving randomly throught the scene, then I have a sphere collider inside a children to detect nearby objects. If ...
0
votes
1answer
59 views

Why is EditorGUI.PropertyField with a custom PropertyDrawer resetting values inside OnGUI of another PropertyDrawer?

I made a PropertyDrawer for a simple class, which looks something like this: ...
1
vote
1answer
35 views

SQL Server Question: How to go about using a collection of cards

So basically I'm new to SQL Servers and for that matter generally to Server Logic and Server behavior. (Used to only work on single player games) OK, so my questions is as followed. Lets take ...
0
votes
0answers
23 views

Using stopwatch to adjust Coroutines running period

I usually see in the code base that we use Stopwatche to adjust coroutines running period in each frame. Questions: ...
0
votes
1answer
64 views

How to find the resulting angle of a ball hitting a wall in 2D

So there's a ball moving on a 2D plane with any vector. When it comes into contact with a collider, it should reflect in a linear fashion. What formula should be used in order to find the angle that ...
1
vote
2answers
55 views

Trying to find a function to calculate attribute changes in a game

I'm coding a game where after every year depending on results the attributes of characters change. The game is a movie business simulator and here is a example of the ugly code I have in place now: <...
0
votes
1answer
52 views

How would I properly flip a character when they reach the edge of a ground object in Unity 2D?

The idea here is that the raycast shoots downwards from an empty game object and when it detects that there is no ground below it the character should bounce back and walk the other way. When I get to ...
0
votes
2answers
123 views

Is there any way to keep the applied torques in the old planes, even if the ship's local plane has rotated?

I'm trying to make a space shooter game in Unity3D with realistic spaceship physics. I have a problem with correct rotations. When I apply torque in global coords system it will always apply them in ...
0
votes
1answer
67 views

Unity3D: activeSelf issues

I've been trying to script some basic AI for a Unity Roll-A-Ball game, which involves two balls collecting cubes for points (one controlled by the player and the other controlled by AI. Everything ...
-1
votes
1answer
44 views
0
votes
1answer
59 views

Managers class losing reference to Game Manager when changing scene in Unity

I've got a singleton set up with a overarching Managers class that has references to each of my other managers classes. I also have a state machine set up that handles changing scenes between the ...
1
vote
1answer
39 views

Creating a letterbox screen for Android devices

I want that the screen looks the same on every Android device without distorting the sprites. One player should not see more of the map than another player just because they have a bigger screen or ...
0
votes
1answer
70 views

How to check whether an angle lies within a specific negative to positive range?

I'm trying to develop a script that detects if an object's angles are tilting too much. I am new to Unity, and I am sure this is not the best way to test an object's angles, but I am trying to learn ...
1
vote
1answer
63 views

Avoiding GC Allocation in Unity UNet API

I'm trying to profile the game using Unity Profiler, I can see in the Hierarchy tab that there's an 18.3 KB correlated to ...
0
votes
1answer
55 views

How to calculate 1st, 2nd, 3rd place and draw conditions in local multiplayer game?

I have a local multiplayer game with an end of round screen that pops up after each round. I'm trying to figure out the logic to calculate the 1st, 2nd, 3rd place from a maximum of 4 players. I also ...
18
votes
2answers
5k views

“The Object you want to Instantiate is null” But it works, can I ignore the error?

This has never happened to me so I'm a bit confused. GameObject someObject = Instantiate (Resources.Load ("Prefabs/Items/" + someName)) as GameObject; This ...
0
votes
3answers
77 views

What to use if you want a looping list?

No, I'm not talking about foreach. I have the following list: public List<float> angles = new List<float>(new float[] { 0, 90, 180, 270 }); This list ...
0
votes
2answers
133 views

NullReferenceException in my inventory system [duplicate]

I'm making a simplified inventory system for a 3d game. When I try to pick up an object, I get the following error: NullReferenceException: Object reference not set to an instance of an object ...
10
votes
2answers
3k views

Why does Unity use reflection to get the update method?

Why does Unity use reflection in order to access MonoBehaviour message methods like Awake, ...
0
votes
1answer
65 views

Element's texture is null - Monogame/XNA, C#

I have a ArgumentNullException everytime I try to call the Draw() method of my Projectile class in the Game1.Draw() method. In Game1.cs Initialize() method: ...
1
vote
2answers
451 views

How to implement ECS architecture in C#?

As C# is a strongly-typed language, I'm having great difficulties associating all my data types together so that I can have a clean, if not performant, game loop. Example #1: Keeping Components ...
0
votes
2answers
123 views

I need help in Unity OnTriggerEnter not changing my bool in an other script C#

I want to change a bool in 2 separate scripts in Unity but it's not changing OnTriggerEnter or stay or exit. I've tried everything but nothing helped me. This is ...
0
votes
1answer
177 views

Have VSync on or off while do a game profiling

I'm trying to profile the game using Unity Profiler in order to catch any potential performance issues. The graphics settings support VSync feature. However, I am not sure which one is the best ...
0
votes
1answer
46 views

Organizing objects into groups of 20. C#

I am building a game where players can build their own airplanes and fly them around. When the vehicle is spawned, all the buildables used to construct the airplane should be placed into groups of 20 ...