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

Exported custom classes or enums are unrecognizable

Is there a way to export custom classes in C# in Godot4.2 that don't show during play in remote the class ID but the class name for instance? Also, exported enums are shown as numbers during play in ...
NitaStack's user avatar
1 vote
1 answer
63 views

How to clean up list entries when objects are destroyed in Unity?

We are developing an economic sandbox somewhat similar to a mixture of The Guild and Kenshi. In this game, both the player and the NPCs will often create and destroy (consume) various objects. The ...
stack_ndx's user avatar
0 votes
0 answers
36 views

Can layermask be made for colliders in Unity?

I use collider to import a few objects in Unity. And these are triggers. Actually, what I want is, for example, there is a wall in front of me and a key behind it, and I cannot get it from in front of ...
Dark's user avatar
  • 1
1 vote
2 answers
28 views

Best way to implement a carrying tray in VR using Unity

I need a way to carry objects on top of other objects in VR without jitterness causing the objects to fall through a tray for example. I've tested with rigidbodies having very high friction, this does ...
Richard Muthwill's user avatar
0 votes
2 answers
62 views

Simulate Velocity For A Projectile Moving Along A Spline

I'm using Unity's latest Splines package(v2.5) to move a projectile across a spline with speed. It works perfectly and the projectile moves across the spline to it's target with linear speed. But I'd ...
PayasoPrince's user avatar
0 votes
0 answers
72 views

NullReferenceException when object is not null

So in the following code: ...
sammyiscuul's user avatar
0 votes
0 answers
49 views

Why can't I limit FPS inside Unity editor?

I have an Unity app that requires a stable fps in editor. The fps itself is really high anywhere from 200 to 280 the problem is that is not consistent. I tried to limit it with the code belove but it ...
Ivan's user avatar
  • 307
2 votes
1 answer
50 views

Detect if a key other than "this" key has been pressed

I'm wondering if there is a way to detect if the key being pressed is NOT matching a specific KeyCode. I tried using: ...
sammyiscuul's user avatar
0 votes
0 answers
20 views

Why when switching between scenes the loading transitions is loading empty scene before loading the scene in index 1?

I have two scenes: Opening Scene and Game Scene. The logic is to play the Opening Scene and then fade out then when the Game Scene has loaded to fade in when the Game Scene is already loaded. the ...
Daniel Lip's user avatar
  • 1,727
0 votes
1 answer
81 views

Converting number in name of gameobject into alpha keycode

So I have no idea if there is a way to do this, but I'm trying to find a way to turn an alpha number in a game object name string into an Alpha key code, which I'm going to use in an Input.GetKey. ...
sammyiscuul's user avatar
17 votes
3 answers
5k views

Game loop isn't performing well enough, so my frame rate is too low (Windows Form + GDI+)

I decided to learn about building games, so I picked up C# to use it along with Windows Form - I already have C# experience, so that was the main reason I did so. That said, I tasked myself to build a ...
curiousguy_08's user avatar
1 vote
0 answers
83 views

Trying to implement undo system

I've got a problem with my undo system that ive made, the idea is I want to make a sort puzzle game like this => https://www.youtube.com/watch?v=VdXi9UQhOng WHAT I UNDERSTAND There is some ...
YouCanCallMe Syarif's user avatar
1 vote
1 answer
61 views

Flying AI shakes when chasing and avoiding obstacles simultaneously

I've got a problem with my flying AI in Unity. When it just chases a target it's ok, but my system contains avoiding obstacles so when it starts to do it, it shakes weirdly. As I understood using <...
kotan4ik's user avatar
1 vote
1 answer
53 views

What would be the best way to gradually increase the speed of a 2D arcade game with gravity physics in Unity?

I'm somewhat new to Unity, so I'd like to hear some more experienced thoughts on this. I'm using C# if that helps. I'm currently working on an arcade game somewhat similar to "Doodle Jump" ...
soxyo's user avatar
  • 13
0 votes
1 answer
28 views

How can I instantiate a prefab in a canvas and have it positioned relative to its parent?

I am trying to load, at run time, a UI prefab and have that display on a canvas. I was following the directions found on this forum. I am able to get it to load and display, but it is not showing up ...
tatmanblue's user avatar
0 votes
2 answers
70 views

Euler Angle X is wrong after using Quaternion.LookRotation

I have an direction that I want the local player hub & camera to rotate at. The game handles this by using euler angles which Y represents the hub rotation on the horizontal axis & X ...
Xprt's user avatar
  • 3
2 votes
2 answers
88 views

Fast way to calculate angular intervals and occlusion of circular objects in a 2D vision cone

Say I have an agent in 2D in a world filled with circular obstacles of different kind and across many scales (some may be very large, practically filling an agent's view, some may be very small). The ...
kram1032's user avatar
  • 121
0 votes
0 answers
29 views

Limiting shooting angle only works when facing right

I have a problem with the shooting being limited when the player is turned to the left side. When I set a range from -145 to 145, on the contrary, it does not shoot into this range, but shoots from ...
Lekr01d's user avatar
1 vote
0 answers
28 views

Issues with bitmap character spacing

I've been working on a bitmap character renderer for my game engine in C#, however, I've been running into some spacing-related problems. This script parses the font and gets all the relevant data ...
Jessica Jones's user avatar
0 votes
2 answers
68 views

My collisions won't work

I have been banging my head against this one for a while. I am trying to implement a pickup mechanic, using OnTriggerEnter2D, however I cannot get it to work, my player just runs past the coin. Code: <...
John Hughes's user avatar
0 votes
0 answers
39 views

Unity clamping local rotation on LookAt issues

I'm new to game development, and I've been trying to code a "smooth camera" rotation that's limited within the camera's local rotation, using a smoothed cube and ...
NovaMaxi's user avatar
0 votes
0 answers
23 views

Second player gets stuck while joining

I get this error message on the console whenever I try to make the second player join. Failed to find a PhotonView with ID=2 ...
zaboombafoo's user avatar
1 vote
1 answer
102 views

Audio won't pause in coroutine

I am making a system where I have one long audio clip made up of voice lines which I want to be able to play one after the other with a variable pause in between. I press the space key to start the ...
Michael's user avatar
  • 41
0 votes
0 answers
45 views

First person jump only works at certain angles

I'm making a basic 3D First Person project using the movement code below, but I can only jump at a certain angle. How can I fix this so that my character can jump anywhere? ...
MarsDarklighter's user avatar
2 votes
0 answers
77 views

How to paint terrain details (e.g. grass billboards) programmatically?

In Unity, is it possible to paint terrain details such as billboarded grass textures programmatically? (The kind that appear vertical and wave according to wind settings.) What I know so far (or think ...
ChurlishCanadian's user avatar
0 votes
1 answer
60 views

Weapon flips upside down when aiming to the left

When the player turns to the left, the texture of the weapon turns upside down. How can I solve this? Shooting Script ...
Lekr01d's user avatar
0 votes
0 answers
124 views

How do I copy GPU buffers in Godot like in Unity?

How would I convert even a section of the following code, which was taken from this GitHub Source to Godot C# or GDScript? I'm trying to make a Godot version of this project, but I don't know how to ...
Ethan's user avatar
  • 145
0 votes
0 answers
23 views

Live notifications using PlayFab

I want to integrate live notification, send/receive, in my Unity game using the PlayFab server. Is there an API call for this?
zaboombafoo's user avatar
0 votes
1 answer
34 views

Game object ownership not transferring and getting destroyed with the master client

I'm using photon pun. I have a spawner script which instantiates the eatables in the gameplay and right after the instantiation, im transferring its ownership to null. The instantiated game objects's ...
zaboombafoo's user avatar
0 votes
1 answer
103 views

Clicking UI button calls event twice

I've designed a game where, when a button is clicked, the moving point stops. If the button is clicked again, the moving point starts moving again. I only click on the button once, but the ...
Alisa's user avatar
  • 1
0 votes
1 answer
45 views

Why can't I press buttons after re-enabling the UIDocument?

I have this UI with buttons that should be clickable whenever the UIDocument is enabled, but for some reason whenever I disable and then re-enable the UIDocument (in the second code block), the ...
skundu's user avatar
  • 1
0 votes
1 answer
50 views

How do I create a backward selection code?

Here is the code for my forward selection: ...
Lucy Adegbayibi's user avatar
0 votes
0 answers
41 views

How to draw new tile on existing tilemap

I created a simple prototype/script which has to draw a predefined tile on an existing tilemap (and highlight the hovered tile). But for some reason, even though it adds the tile to the correct place, ...
Suule's user avatar
  • 101
0 votes
0 answers
57 views

Does adding a new dictionary key-value remove other elements?

I'm using Unity Engine with C#. Currently, I have a weird issue. Here's the code for my dictionary: ...
modernator's user avatar
  • 1,193
0 votes
0 answers
85 views

How to make a hole of N vertices in the face of a Cube

I want to make a hole of N vertices in the face of a Cube, I'm adding just four like a square in this post to be simple, but eventually I want to be able to add as many as I want and maybe in a ...
ガブリエル Gabriel's user avatar
0 votes
0 answers
28 views

How to keep music playing continuously when switching scenes? [duplicate]

I added music to my game, but it restarts when transitioning between scenes. I want it to play continuously without interruption. What should I do?
ali aydınlıoğlu's user avatar
0 votes
2 answers
81 views

How to remove loading delay when loading from Appdata? Or to load everything at start?

Currently, when loading from Appdata, there is a noticeable delay. See a sample video here, when it changes from the sprite set in UI to the sprite loaded from Appdata through C# script. I want to ...
Junjie J2's user avatar
0 votes
0 answers
26 views

Enable socket interactor only when previous sockets are occupied

There are 3 boxes and 3 socket interactors. I only want the second socket interactor to work when there is a box in socket one and the third to work when there is a box in the first and the second ...
SPP's user avatar
  • 1
0 votes
0 answers
46 views

"SpriteRenderer does not contain a definition for SetBoneTransforms" error after downgrading Unity version

I built a project with Unity version 2023.3.0a and I had many problems with this version so I opened my project with version 2022.3.10f1, but I have some errors. I tried to reimport my project ...
Ali Ahmed's user avatar
-1 votes
1 answer
67 views

unity onTriggerEnter does not work

so in here there is a box to which i have attaches this script and ATTACH1 is a socket interactor here i want is when the box which i have attaches attaches to that socket interactor the text which is ...
SPP's user avatar
  • 1
0 votes
0 answers
61 views

How to stop object with joints flying away at high velocity on collision?

I am currently making a game where the player constructs vehicles out of blocks. I am achieving this through having rigidbodies for each 'group of blocks' separated by 'function blocks' (e.g. motors, ...
Renexx's user avatar
  • 1
2 votes
0 answers
58 views

Wrapping a mesh around another

I want to add LED strips to objects at runtime. The led strip is a very simple rectangular mesh that is generated at runtime. A shader then just draws LEDs down the length of the strip. Here is an ...
Charl Cillie's user avatar
0 votes
1 answer
39 views

Why is the grid's Z coords = -10

I'm using mouse input to move the player from where they are to where the mouse position is relative to the cell on a tilemap. However I found when I click on a point of the tilemap, the z coordinate ...
Maeson Williams's user avatar
0 votes
0 answers
36 views

How can I write the same code, but for Cinemachine?

I have a code for recoil, and this recoil rotates the camera upwards, and then returns smoothly back to the starting point.So, when there is a Cinemachine Virtual Camera component on the camera, the ...
Ivan's user avatar
  • 1
0 votes
0 answers
96 views

"Unable to create keystore" message from Unity for Android

I want to build a project with a release aab version. Unity asks me to create a keystore, and when I create one, it show this message: Android/2023.1.911/Editor/2023.3.0a6/Editor/Data/PlaybackEngines/...
Ali Ahmed's user avatar
0 votes
1 answer
31 views

"Button is not an attribute class" error when integrating Steam achievements

I am writing the code for my button, but it's giving me errors like this: Assets\Scripts\SteamIntegration.cs (60, 6): 'Button' is not an attribute class Where did I make a mistake in this code? <...
Syeda Aqsa Sakina's user avatar
0 votes
1 answer
70 views

How to save and instantiate game data containing lists of polymorphic types

Let's say I have a class named Entity such as: ...
Trobibot's user avatar
0 votes
0 answers
44 views

How to adjust resolution to display only in portrait mode for both phones and tablet devices?

I am facing an issue where I'm able to adjust the resolution for different phones like Android and iOS but not for tablet devices. Is there any way to set it, for all kinds of devices, to display only ...
Mohammed Rilwan Ibrahim's user avatar
0 votes
0 answers
39 views

Enemy not responding to chained attack

I am working on a 2D mobile platformer where there will be different characters with unique skill sets. I am working on a character that should be able to perform chained attacks. I have a button in ...
shanksVR's user avatar
1 vote
0 answers
39 views

Move UI element by a specific amount relative to current screen resolution

I want to achieve the following: At some point in the game, the UI Image (dashed rectangle) should shift towards the right edge of the screen (black outline rectangle) up until the part of the image, ...
Russel Ledge's user avatar

1
2 3 4 5
166