Questions tagged [c#]
C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.
8,482 questions
3
votes
1
answer
119
views
What’s the correct / idiomatic way to pause a game in Unity?
I'm trying to implement a robust pause system in Unity and I'm confused about the correct approach. My first (very simple) implementation in my previous project used a ...
0
votes
3
answers
132
views
How do big open worlds handle Object Pooling?
Object pools are great. They are fun to make, save you a lot of memory and fps.
But as my projects grow in size and complexity it gets harder and harder to work with them. If you only have a couple of ...
0
votes
2
answers
79
views
How would I make a "slideshow" cutscene?
I'm making a 2D game using Unity and I want to implement cutscenes that change over at certain lines.
...
0
votes
0
answers
41
views
Static event not working on scene reload(SceneManager.LoadScene();)
(Maybe good to know, this game is part of a game dev course where we had to make a Vampire Survivors like game)
I thought SceneManager.LoadScene() reloaded EVERYTHING in a scene, like a clean state, ...
0
votes
1
answer
36
views
Transform is not available in SystemBase Script (Unity Entities)
My player is baked entity in subscene while main camera is outside on scene. For some reason system cannot find transform of camera, GameObject was found though.
<...
0
votes
0
answers
61
views
Aligning OpenStreetMap data with Cesium 3D tiles
I have my OpenStreetMap data exported using QGIS as a gltf file, and I'm trying to align it with Cesium 3d tiles for my high resolution model.
The problem is that both have different coordinate ...
1
vote
1
answer
71
views
Change sprites for multiple image in one function
I am trying to make a digital clock (24:00 type), where each number is an individual image, that should change. So, I want to change sprites for multiple images in one piece of code.
But when I ...
0
votes
0
answers
118
views
Why does this code behave strangely with different camera angles?
Relevant to this issue are two MonoBehaviour scripts: Actor and Player. ...
0
votes
0
answers
50
views
Is a shader easier or scripting easier in terms of creating a panel behind objects
My unity project is 2D universal.
My goal here is to create a comic-like panel with outlines behind objects that have certain tags. This panel should follow the rotation and size change of said ...
0
votes
0
answers
61
views
Need a Hand with Liquid Shader in Unity (for VR Bartending Game)
I’m working on a liquid shader in Unity and could really use some help making it look more realistic. I’m going for that nice touch of transparency, reflections, maybe a hint of refraction—just ...
0
votes
0
answers
62
views
How do I use Addressables AssetReference RuntimeKey to compare the loaded assets with the AssetReference
I will use Addressables to load multiple assets of type Bag that share the same AssetLabelReference.
So I will load them using ...
0
votes
1
answer
129
views
Modular Pathfinding Between Connections
I'm creating a puzzle for my game, where you have to arrange pipes to transmit an electrical flow from one point to the other. Each pipe center contains a connector hub and each end contains the ...
1
vote
2
answers
463
views
How do I implement the "collide and slide" algorithm in Unity?
I've recently been attempting (and failing) to create my own character controller for my 3D Unity game for around a week. I hate the Unity rigidbody physics system for making a character controller, ...
0
votes
1
answer
103
views
Why isn't my object following the target?
I don't understand why my object does not follow the player. I instantiate the character with the PlayerPrefs I saved from another scene. However, the object tracking code does not follow, and also ...
1
vote
1
answer
63
views
CapsuleCollider2D hitbox fails to trigger when player/enemy are stationary
I'm currently working on my first game in Unity, and I'm having some trouble with attacking. Currently, I have a game object with a 2D capsule collider child. When the attack button is pressed, the ...
1
vote
0
answers
116
views
How can I address multiple collisions within a single frame?
So, in my breakout clone, I've encountered issues where the ball will sometimes phase through bricks and the borders if it collides with one and then immediately collides with another after. My guess ...
0
votes
1
answer
120
views
How to instantly stop when moving the character with AddForce?
I made character movement using AddForce. But I don't understand how to get the desired effect. I need that when I release a movement key (for example WASD) the ...
1
vote
1
answer
182
views
How can I make liquid in my vr bartending game
I'm working on a realistic VR bartending game for Quest, and I need some help with making bottles pour liquid into cups. I'm aiming for a system where:
When a bottle is tilted, liquid pours out ...
0
votes
0
answers
31
views
Bug Canvas image being stuttered when move follow player?
I tried to code an image to follow the character using canvas but it jerks when moving. Is this a bug? Do you have any solution to fix it?
https://youtu.be/OnT9Pabgi2g
...
1
vote
1
answer
126
views
Two Point Alignment Transformations
I'm trying to determine the transformation steps (position, scale, rotation) needed to be applied to an object so that two points, locally positioned in that object, line up with two world space ...
0
votes
0
answers
68
views
How to disable lobby/relay for a project in Unity?
Me and a friend created a basic multiplayer game in Unity using Netcode For GameObjects. We also used Lobby and Relay Gaming Services to make it easier to play with each other.
There is only one ...
2
votes
0
answers
67
views
Best Approach for Storing / Serializing Property Value Animations
Background
I'm making a platformer game, in C#, in Monogame. I've got a middling amount of experience with gamedev, having done some mini projects in Unity in the past and deciding I don't like a big ...
4
votes
3
answers
3k
views
How to avoid cycles when one character stat can be enhanced by another?
I am creating an ability system in Unity and it is currently able to update base values of stats and keep track of persistent buffs/debuffs while taking operation order into account (Add, Increase, ...
0
votes
1
answer
96
views
Lerping Time.timeScale causes laggy physics
I am using unity as my game development platform. I was trying to create script that could interpolate time scale to achieve a flurry rush.
The code below is my attempt:
...
0
votes
0
answers
60
views
How to code marking dead stones in Go board game. Getting user input outside of update
This is a follow-up question to coding capturing in Go. I have that successfully working. I am pretty sure that I am not reposting, this is a completely different question I have it just happens to be ...
1
vote
3
answers
263
views
Is it possible to set a specific frame rate on my game
For the past month i've been working on a vr project and i wonder if i can obliged players to be on 90hz when playing the game because if player use 60hz then the game becomes laggy and since 90hz is ...
0
votes
1
answer
124
views
Null reference exception when accessing ActionMap stored in a singleton
I'm a beginner developer and I'm currently working on a 3D game project with a third person view.
When I implemented my first ActionMap into my character controller,...
1
vote
0
answers
119
views
Creating a large number of GameObjects asynchronously
I am creating a 2D procedural terrain using many Tile GameObjects. To make this infinite (and more performant), I dynamically load and unload chunks based on the players position and a variable ...
0
votes
0
answers
91
views
Why is raylib not drawing one corner?
I have simple raylib code here:
...
0
votes
2
answers
85
views
Get the path of a sprite without UnityEditor.AssetDatabase
How can I get complete path of a sprite? describes how to get a sprite path using UnityEditor.AssetDatabase which isn't available in builds. I need a way to get the ...
2
votes
1
answer
139
views
How to plan the animation of a complex combat between two groups of units?
I'm working on a turn-based tactics game in Unity3D/C# in which players control Detachments composed of multiple Units. Each Detachment occupies one hex on a map, and may contain up to one each of ...
0
votes
1
answer
96
views
How can I get Unity multiplayer hosting as affordable as possible?
What are my options with Unity to host a multiplayer server as cheap as possible? Preferable if it's also avaliable in Russia.
1
vote
0
answers
91
views
A simple, private and secure way to send myself telemetry data during beta testing
I'm creating a game in C# with Unity. I want to know how I can send myself telemetry data (e.g. how long it took the player to complete the level) in the code in a way which is easy to set up and ...
0
votes
0
answers
98
views
Understanding C# Tasks
I use a lot of path finding in my Monogame project which is taking a toll on the framerate, because in the worst case finding a path can take 200ms. So I looked into using Tasks to spread path finding ...
0
votes
1
answer
85
views
Have enemy move toward player when spawned
Have an basic enemy prefab that when spawned, I would like it to lock to player and move toward them, with smooth rotation. However, as you can see in this video, the enemy initially moves away from ...
2
votes
0
answers
103
views
Intercepting joystick/gamepad movement
I’m developing an accessibility app that allows users to navigate Windows using a game controller. The app works by using the left joystick to move the mouse and the right joystick to perform actions (...
0
votes
0
answers
47
views
localPosition for UI object gives different results from its values in the script
Here is my script for opening animation. It basically sets the localPosition of an object out of the screen and then brings back in smoothly. The problem is I got ...
0
votes
1
answer
53
views
Did they change how Player Input SendMessage works when sending messages?
When I first used it I remembered it as always calling the specific method once. So if I created a Jump Action with the key binding of space using SendMessage:
and then created a method for it:
...
0
votes
1
answer
116
views
Teleport to random point behind Camera and within boundaries
I'm creating a third person game with companions following the player. The companions have a mechanic in which if they are too far away from the player and out of camera view, they'll be teleported ...
0
votes
1
answer
101
views
For some reason, autocompletion works even though it's "Disconnected."
I installed the following extension: https://marketplace.visualstudio.com/items?itemName=woberg.godot-dotnet-tools
but I'm not sure if it's actually related to autocompletion. I've tried turning the ...
0
votes
0
answers
66
views
How can I get a response back from my server running a udp socket between my server and home?
I have a c# udp socket I'm trying to send data from to my home. The server socket is hosted at aws, and the client is at my house. I modified the code from the following GitHub to send a response back ...
0
votes
0
answers
83
views
Rotation Matrix rotating in context over another Rotation Matrix
I have 2 rotation matrixes than work in a world that have three dimensions (X, Y and Z) being Y the one of the height.
One of such rotations works using Y dimension, from the point of the center of ...
0
votes
0
answers
45
views
Player's speed staying constant
I'm having a problem with the code below. My player is always moving at the same speed. Even if I give my boast variable a very small value, the speed remains same ...
1
vote
1
answer
153
views
How do I render a sector (pie/cake slice) of a circular Unity 2D GameObject?
I have a circular GameObject in Unity 2D with a SpriteRenderer attached.
I want to attach a custom component to my ...
0
votes
1
answer
64
views
Unity FromJson Utility Not Populating Instance of Class
I've used FromJson in Unity/C# a dozen times, and yet for some reason I cannot figure out why this one's not working.
Here's the code that does the parsing:
...
0
votes
0
answers
59
views
OpenTK (C# OpenGL) Coordinate mistake
I am trying to make a 2D renderer using OpenTK and I am having trouble with the coordinate system. I have followed an opengl sprite tutorial and the Size vector is ...
0
votes
1
answer
224
views
3D Dark Souls lock-on code: Player moves around target in a spiral, not perfect circle
I'm working on a 3D game in Unity that requires lock-on, or Z, targeting found in games like Dark Souls and Legend of Zelda: Ocarina of Time.
The code that I have achieves my intended goals fairly ...
1
vote
0
answers
27
views
How can I fix this display error with my custom DCPU-16 for Unity?
I’m trying to recreate the DCPU-16 for Unity that has a console and can render the output to a TMPro text on a canvas. What the code should do is display A B C onto the TMPro text, but nothing appears....
0
votes
0
answers
30
views
When connecting a Character Controller component to a character, it starts to rotate uncontrollably
When connecting a Character Controller component to the character in Unity, it starts to rotate uncontrollably. Without the Character Controller, everything works fine, but the character does not walk....
2
votes
1
answer
226
views
How can I instantiate prefabs from a non-MonoBehaviour script?
I'm trying to instantiate prefabs in Unity, but I want to do it from a script that doesn't inherit from MonoBehaviour.
I understand that a ...