Skip to main content

Questions tagged [c#]

C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.

Filter by
Sorted by
Tagged with
0 votes
1 answer
13 views

The WebGL version of my game does not load the next scene when using an async action

I've just created a WebGL build for my puzzle game in Unity. While the Windows version worked just fine, I encountered a bug on the web: it cannot load the next level when you collide with the goal. ...
Nghia Tran's user avatar
0 votes
0 answers
30 views

ReleaseInstance is not deleting the object instantiated from an Addressable

I have this simple script, which is working perfectly when I press I and it instantiates an addressable game object. But I am not sure why it is not deleting it when I press D. I confirmed that on ...
Muhammad Faizan Khan's user avatar
0 votes
0 answers
17 views

FirebaseReference.GetValueAsync() in Unity Not Completing

I'm working on a Unity project where I use Firebase to manage user data. I am encountering a recurring issue where the asynchronous task GetValueAsync() does not ...
Jose Lopez's user avatar
1 vote
1 answer
33 views

how can I distance camera according to player speed?

How can I make the camera move further away from the player according to player's speed? So, the camera is at default distance, but when the player catches a boost (increases speed), the camera ...
jukvox's user avatar
  • 13
0 votes
1 answer
77 views

Why doesn't Coroutine work the way I want with if blocks?

I'm making a game and when the enemy dies I keep it in memory. I want the person playing to find the game just as they left it when they enter. I'm doing most of these, but there's one small problem ...
Volkan AKDAG's user avatar
0 votes
3 answers
58 views

How to make camera follow player on Y+ axis only

My player is jumping on sticks, endlessly going upwards, and if they fall, it's game over. I want the camera to follow the player only when they move up (ie. only on Y axis), not down. If they move ...
jukvox's user avatar
  • 13
0 votes
0 answers
39 views

About Json format and Player Prefs [duplicate]

I'm making an Offline RPG game in Unity. I want to save some things in my game. I have heard of two recording systems for this, one is PlayerPrefs and the other is to save in json format. PlayerPrefs ...
Volkan AKDAG's user avatar
0 votes
0 answers
28 views

Compensate bullets direction towards direction player is moving in

My new prototype is a top down shooting game, the player aims with the mouse and fires projectiles towards the mouse position, this works fine, when the player is standing still. When the player moves,...
Mad Hatter's user avatar
0 votes
0 answers
56 views

bad position of contact points :why?

...
kaloprat's user avatar
  • 111
1 vote
0 answers
22 views

How do I get a Unity Job to update external data?

I'm relatively new to Unity, and I wanted to use the Job system for a complex pathfinding algorithm, since it will likely be used alongside multiple instances of NPCs attempting to find a valid route. ...
Jason Li's user avatar
0 votes
0 answers
44 views

Multithreading Chunkbuilding - Thread.Start() acts as it is on the main thread

I'm building a game from scratch using OpenTK, in C#. It is in its base form a mesh-based voxel engine. I have a decent startup on the chunk building algorithm, multiple blocks, block data, etc, but ...
Pale_Gray's user avatar
0 votes
1 answer
39 views

Draw Primitives using SharpDX.Direct3D9 with C# .NET Framework

I have a question, How to draw primitives? draw lines, rectangles, circles, text, etc... For now I can draw text and Lines: SharpDX.Direct3D9.Font SharpDX.Direct3D9.Line However, those lines look ugly,...
S4L salsoft's user avatar
0 votes
0 answers
28 views

How could I generate a large 3D mesh from a 2D texture at runtime?

I have a simple black and white texture, where white is a biome, and black is outside of the biome. I want to create a mesh at runtime that is the same shape as the white region and has a ...
Noah Vanilla's user avatar
0 votes
1 answer
24 views

scale and rotate a cube automatic the cube is never scaling and rotating to the end. how to fix?

the scaling and rotating both are working. if the automatic flag bool is false and i press the G key each time i can see that the cube is scaling and rotating to the end for example if it's rotating ...
Daniel Lip's user avatar
  • 1,747
0 votes
1 answer
29 views

How do I move both the child & parent game objects at the same time?

My current code is: ...
Saltii's user avatar
  • 1
0 votes
2 answers
60 views

Type or namespace name 'Collider' could not be found

I asked Mail.RU how to make a script so that when an object is touched, the game will restart. They sent me this: ...
лис 3's user avatar
1 vote
2 answers
44 views

Different Spacing of all Children Grid Layout Group

I am creating a top down 2D game, and I am creating randomized triangles on the ground. Such as this: This is to enhance the "knowledge" that you are moving. But it certainly doesn't look ...
sammyiscuul's user avatar
0 votes
2 answers
114 views

How can I securely store Gmail SMTP credentials in a Unity project to comply with security guidelines?

I am currently working on a Unity Asset that involves sending emails using Gmail's SMTP server. As part of the setup, developers using the asset are required to input their email address and the ...
Ch.Muhammad.Bin.khalid's user avatar
9 votes
2 answers
4k views

Avoiding string literals to reduce memory allocations

In Unity, should we avoid string literals in frequently executed methods (like Update()) to avoid unnecessary memory allocations and instead store string values ...
Srdjan Pazin's user avatar
0 votes
1 answer
63 views

Why are my angle calculations not working properly?

I am using this code: ...
Stan's user avatar
  • 3
0 votes
2 answers
88 views

Kinematic "dive bomb" motion toward a moving target

Context: infinite runner, stationary player, obstacles move toward player. I have an asteroid that currently Vector3.MoveTowards a moving target e.g. a "rubble&...
David Fox's user avatar
  • 123
5 votes
1 answer
765 views

How to make an authoritative server assign turn order numbers to players once they join?

I'm having trouble developing and understanding Server code. Currently, I'm trying to have each person that joins the Server be given a single digit ID that can then be used for determining turn order ...
SmileyTheMimic's user avatar
2 votes
2 answers
122 views

Turn a 2D array into a 3D map

I have a C# script that creates a random 2D array that is a map for a cave system. Sample Map: ...
AndyD273's user avatar
  • 163
1 vote
3 answers
97 views

Unity Game Architecture

I'm working on a relatively simple game, but even simple games have a lot of moving parts, and I'm running into some architecture issues. Just to be clear, everything works fine, but it feels dirty, ...
manwithcode's user avatar
0 votes
1 answer
36 views

Understanding transform.forward vs. Converting World Space Forward to Local Space for Ray Drawing

I'm working in Unity and trying to visualize the forward direction of a GameObject. I came across two approaches: Using transform.forward: ...
Abhinay Singh Negi's user avatar
0 votes
2 answers
110 views

Why are Quaternions better than Euler-Angles for Godot (when to use which)?

Sorry about the click-bait, I know there are many many reasons why Quaternions and Bases are better than using Euler-Angles. Anyone on a 5 second google search could easily know why! But I am trying ...
ZenPyro's user avatar
0 votes
0 answers
48 views

Creating Prefabs during AssetPostProcessor from the imported asset

I'm trying to create an automation for our asset pipeline where an imported mesh will automatically be processed into prefabs for each instanced submesh. For example, when I import this FBX ...
Echoleta's user avatar
  • 143
0 votes
1 answer
73 views

Turret following the player in the opposite side

i have tried using lookout method then flipping it by 180 degress but it gives me the same result as the problem i had before. my turret turns left when i move right and vica verse. To fix this i used ...
NEWBIE's user avatar
  • 23
1 vote
2 answers
135 views

How to implement C# methods that automatically get called in the game loop, like Unity's Update() etc.?

I've been working on my own game engine for some time, I ideally need a way to create global function implementations to make it easy to do things within the game loop. Heres an example: ...
Pow's user avatar
  • 383
0 votes
0 answers
43 views

Frustum culling works correctly but results in flickering meshes

I've written a C# code and Compute Shader that makes frustum culling and it works correctly but it makes the grass flicker. I can't figure out what is behind this issue so I'm asking here. Does ...
Leedy's user avatar
  • 1
0 votes
0 answers
65 views

Frustum culling using compute shader, how?

I'm working on a little project for a while - creating an area where you can spawn a bunch of grass. I've overcame a major headache when figuring out the GPU instancing for the mesh and the code looks ...
Leedy's user avatar
  • 1
1 vote
0 answers
43 views

When making an object that interacts with things, is it better to have one big script or several different small scripts [duplicate]

Im working on a game inspired by Buckshot Roulette but medieval themed, in Buckshot Roulette the weapon can be picked up by the player, who can then point it at themselves or the "dealer", ...
Ulver04's user avatar
  • 11
0 votes
0 answers
46 views

GLWpfControl and OpenTK force graphics adapter

I am using GLWpfControl and OpenTK for a Game that I'm developing. The game has a lobby which runs on WPF and C# and I used GLWpfControl for the OpenGL stuff. The problem lies on my laptop that has ...
Mike F's user avatar
  • 93
1 vote
2 answers
100 views

How do i get key input using c#

To change key configuration i need to get the key input but after looking around i havent found any way of doing that using c#.The other way is using the Gd programming language.but i cant do that as ...
NEWBIE's user avatar
  • 23
0 votes
1 answer
63 views

Camera movement automatically tracking a tool over a surface

I need to create camera movement tracking the clipper hair like this: I already have a script for the movement of the tool. I'm using Snapping Player to the Surface of an Object of this pos How ...
Lưu Anh's user avatar
0 votes
1 answer
40 views

How to get difference in rotation between 2 objects, but only on one axis

Say I have 2 cubes that start with the same rotation. I wish to track the rotation difference between the 2 about the z (forward) axis. Such that if cube A remains stationary and cube B rotates 30 ...
ThatOneGuy's user avatar
0 votes
2 answers
102 views

Is it wrong to leave references objects in the game world like 99999 units away

It's hard for me to explain my question with an example. But essentially, I have a game with many craftable items. Each item is a prefab. Each item has many unique scripts and functions on it. ...
Frank's user avatar
  • 121
2 votes
1 answer
70 views

What does Unity do with a Prefab's Start function when it is assigned to something in the editor?

Unity C#. This is a hard question to phrase, an example explains it the best: Setup Create a GameObject called Thing. Create a script ThingScript and attach it to Thing. ...
Frank's user avatar
  • 121
0 votes
1 answer
51 views

How to get value of transitionDuration in C# for Unity UI Toolkit

My existing code for this task is: ...
Mfa Xyz's user avatar
  • 11
0 votes
0 answers
25 views

Detected the Mesh's Specific material under the click in unity

I have a mesh in unity which is made of several materails. Now if i click on it on a specific location of the mesh, i want to pick its selected materail. Actually the mesh itself have several ...
Muhammad Faizan Khan's user avatar
1 vote
1 answer
84 views

How do I get a client side health bar to update? Netcode for gameobjects

I am working on a multiplayer prototype and am trying to get health bars working. It's working on server side and health is working and subtracting from client side with a network variable, however I ...
WestMansionHero's user avatar
1 vote
0 answers
36 views

Stop Jitter On Rigidbody2D From Rotation

I'm currently working on a geometry dash like game, except it is a triangle instead of a square (rubrub calls it a cube). I want it so that it rotates back to 0, 0, 0, when it is touching the ground. ...
sammyiscuul's user avatar
0 votes
1 answer
88 views

How to serialize data from C# in a non-human-readable way?

How can I serialize a C# object (class, struct, etc) to a file without that file being easy to read? Binary Formatter First I used the Binary Formatter, which worked really well, but there were a lot ...
Pow's user avatar
  • 383
0 votes
1 answer
79 views

How can I store a list of instances of different classes?

I am making a customizable save system for Unity. In my previous save systems, since they aren't designed to be modifiable, I already know what each save is going to contain. However, when making this ...
Pow's user avatar
  • 383
1 vote
0 answers
67 views

How to implement soft-body blobs that don't pass through one another

I am learning about soft-body implementations in Unity recently, and I stumbled upon the game Blob Merge 3D. It is quite an interesting implementation because the blobs do not overlap one another and ...
creekat's user avatar
  • 11
0 votes
1 answer
35 views

Error converting singles and floats

I have a custom data type I made called a point. It has implicit operators to easily convert between a Vector3 and a float[], the reason being Vector3 and Vector2 types are not ...
Pow's user avatar
  • 383
0 votes
1 answer
47 views

Want get rotation based on the details of four corners of a square

I got four corner points of the object which are topLeft, topRight, BottomRight, BottomLeft and are as clockwise. I want a rotation values in X, Y and Z for unity object to rotate based on the ...
Yagnik Joshi's user avatar
0 votes
1 answer
44 views

Using an InputField to enter a distance and then move an object to a location based on the input: object returns to old position

I have attached a script (1) to the InputField for ease and it displays HA changing when I alter it during run time in the ...
Stan's user avatar
  • 3
0 votes
1 answer
93 views

My CharacterBody3D Is getting blocked by ramps that act as walls

To summarize, my ramp is acting like a wall even if it is created to have a collision and mesh that fits its shape. I have tried: Putting the max angle to 90 using different ramps (CSG & mesh) ...
NEWBIE's user avatar
  • 23
0 votes
1 answer
17 views

Unity UI Builder InvalidCastException

I am making a custom UI with the UI Builder for my scriptable object that holds some data for the AI Player. It all worked fine until I added a third slider for a new value I needed; now the object ...
Džoni's user avatar
  • 36

1
2 3 4 5
168