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,286
questions
0
votes
1
answer
155
views
0
votes
1
answer
95
views
Why doesn't RectTransform.GetWorldCorners() employ any camera?
Typically, conversion methods from world to screen coordinates and vice versa use a camera to perform these calculations, so I'm wondering how does GetWorldCorners ...
0
votes
1
answer
75
views
How to use WASD to move camera between a collection of position marker objects?
How can I move one camera between two positions along the cardinal directions?
Using W/A/S/D keys, I want to move the camera from one empty object to another on the xy plane. Those empty objects ...
0
votes
0
answers
44
views
How can I clearly distinguish between tap and swipe inputs on mobile?
How can I clearly distinguish tapping and swiping touches?
This is my interaction script:
...
0
votes
1
answer
154
views
Problem with JSON ScriptableObject saving using NewtonSoft JSON
I am saving a list of ScriptableObjects in a JSON file using NewtonSoft JSON, the problem being that the following error message is thrown when it tries to save:
<...
0
votes
0
answers
125
views
"rigidbody property has been deprecated" when trying to save ScriptableObject to JSON with NewtonSoft
I am using NewtonSoft Json to save data in my Unity game, but when I try to save something it get this error:
...
0
votes
0
answers
42
views
Physics2D.OverlapBoxAll misses small overlap
I have a tetris-like 2D game with tiles, each made up of a sprite, a Rigidbody2D and a BoxCollider2D.
The tiles fall from the ...
0
votes
0
answers
27
views
ComputeShader.SetTexture() isn't writing to the shader
The C# script:
...
1
vote
1
answer
47
views
Move object continuously along y with optional movement along x
I am looking for a sensible way to continuously move an object downwards with constant speed while moving left or right by some amount x when the user presses the left or right arrow keys.
Basically, ...
0
votes
0
answers
42
views
How to make action get triggered as long as key is held in Unity new input system
I'm using unity new input system for a local multiplayer game.
My PlayerInput sends messages to my CharacterInputListener on every character object, one of such messages is OnDefend().
I want ...
1
vote
1
answer
95
views
Why Does Offsetting Perlin Noise Cause Zooming In To No Longer Work?
I am creating a game in which a world map is generated using Perlin noise, and then specific points in the map are rendered using higher resolution Perlin noise. I am trying to do this by zooming in ...
0
votes
1
answer
40
views
How can I prevent my ball from slowing down when it makes contact with the corners of colliders
I'm trying to make a game where the player has to destroy blocks. But when the player collides with the corners of the blocks, the player's velocity slows down, or even stops.
How can I ignore the ...
0
votes
0
answers
35
views
How to set reference to a c# file using an exposed field from a scriptable object?
Can't wrap my head around this, In my game I have the following:
SpecificItem.CS - different items that have different programmed functions/methods into them.
SpecificItemDataContainer.CS - scriptable ...
0
votes
1
answer
31
views
3rd Button on UI Seems to not Register the onClick.AddListener()
I have a UIManager meant to control the UI. The UI manager is attached to an empty game object.
The Canvas has three panels, ...
1
vote
2
answers
221
views
How can I solve this error and this warning when destroying instantiated prefabs?
I'm working on a level in a 2D game that includes two big triggers.
Each time the player enters them, I Instantiate an enemy prefab. Then, the player can shoot ...
0
votes
1
answer
103
views
How to check if a 2D GameObject is touching something without OnTriggerEnter
I want to avoid using OnTriggerEnter2D because I want to use it in a function like this:
...
0
votes
1
answer
62
views
Detect which child Triggered inside parent script in Unity
I have a parent gameobject with rigidbody and parent script. The gameobject has many children and each child has Box collider and "is Trigger" option is on.
When each child collide with ...
0
votes
0
answers
62
views
Trying to get a Character to face the direction based keys pressed left or right instantly
I finished up my movement script which is finally working fantastically. The only issue I am having is getting the character to face the direction when I press either left or right on the keyboard. ...
0
votes
1
answer
115
views
How to convert a Unity transform to Maya's coordinate system?
I created a level in Unity, and I want to place some of the level objects in Maya so I can create an animation based on these objects.
I can import the model FBX with no problems into Maya, but if I ...
1
vote
0
answers
65
views
Voxel Point Cloud Transformation (Rotation & Translation)
I have a method that transforms a point cloud and aligns it with its gameObject.transform. My method works well, but i have to rotate the cloud, and then I have to use an approach (taking from 2d ...
9
votes
3
answers
2k
views
What's the appropiate way to achieve composition in Godot?
How?
I think I still don't properly understand how composition in Godot works. So, as far as I know, you 'compose' stuff in Godot, right? Like, if you want to make a rock you create a mesh node with ...
0
votes
1
answer
315
views
Why does my unity Cinemachine camera that follows the mouse only rotate on the x axis not the y axis
I've recently started work on a 3rd person game and want the camera (cinemachine virtual camera) to rotate with the mouse while following the cinemachine camera, it would be best described as when ...
0
votes
0
answers
124
views
How does Monogame achieve a target FPS?
So in monogame, in your Game1 class you can write something like this:
...
0
votes
1
answer
45
views
Rotating around 3D cube Camera Controller for Unity
I am Unity game developer with more than 2 years experience. I am working in a personal project, a mobile game for Android in Unity.
I am trying to make a camera controller for a 3D Cube Game in Unity....
0
votes
1
answer
77
views
Animations don't transition when prefab instantiated by code
I am working on a script that responds to the player pressing a button by instantiating a prefab into the scene.
The problem is the animation is not working on the spawned prefab. The conditions of ...
0
votes
1
answer
176
views
How to hide UI elements in Unity?
I'd like to ask a case when developing a game using Unity.
There are many UI elements in the game.
These UI elements normally disappear from scenes when the purpose is achieved.
However, the ...
0
votes
0
answers
71
views
Input axis defined but not working
I'm trying to use a simple code example to move a square object like this:
...
0
votes
0
answers
121
views
Unity fails to build Android player, gives ambigous error
I'm trying to build an android player, (worked like a charm yesterday), and I'm getting a single error when it fails
...
2
votes
1
answer
635
views
How do I handle lists/arrays in Unity DOTS/ECS?
I'm new to ECS and am having issues finding the right data structure to use.
For context, I have a galaxy with solar systems that produce resources at a given rate (...
0
votes
1
answer
82
views
Why isn't my code running?
I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if ...
0
votes
1
answer
28
views
How can I check which of an object's colliders was touched during a collision?
I my game, I am trying to create a door/loading zone system, in which a GameObject has several loading zones as children, each with triggers as components. Also attached to each of the loading zones ...
0
votes
1
answer
107
views
smoothly transition from an animation layer to the other in unity
I have two layers of animation and I'm trying to SMOOTHLY transition between these two layers when I click a button.
...
0
votes
1
answer
67
views
Why the camera is never looking forward direction and always looking down?
While the camera(transform) is moving between the waypoints I want that according to the CameraViewMode enum selected option is the direction the camera will look at.
The BirdsEye mode is always the ...
1
vote
0
answers
470
views
`Graphics.Blit` into a render texture using a custom material outputs black
Context
I am writing a ScriptableImporter for a specialised image format (the specifics are not relevant). To do so, I need to semi-procedurally generate a ...
0
votes
1
answer
105
views
How to create custom UI element from Hierarchy Menu in Unity?
I have a custom UI element and I would like to instantiate it from Hierarchy like you do with any other UI element (button, text etc.). I know how to do this so it is instantiated in the scene but how ...
1
vote
1
answer
87
views
Unit Testing start method of a MonoBehaviour
In Unity how can I unit test the start method?
I am not trying to test interaction between objects but the private methods are called by the Start method, so I figured I should call the start method ...
2
votes
0
answers
64
views
Capturing the undo/redo Unity shortcut when a custom EditorWindow has focus
I'm working on an editor tool which can have multiple windows to edit different files at the same time. I'd like to implement my own undo/redo functionality, independent for each window, and ...
0
votes
1
answer
272
views
Is it possible to detect if the cursor is over a GameObject with a specific tag?
I've tried quite a few things, but none of them have worked reliably. Here is what I'm currently using:
...
2
votes
1
answer
155
views
Stride integrated in WPF or WinUI desktop app
I am using stride 3D engine integrated in an UWP application because stride only support this platform.
Do you know if it is possible (or one day) to integrate stride in a WPF or WinUI application ...
0
votes
1
answer
41
views
How do i know when the objectsList have all the objects after the nested method loop finished?
For example let's say the depthLevel value is 2 and then in objectsList there is 76 items.
...
0
votes
1
answer
60
views
Smartphone tilt calculation when using gyroscope in Unity (smartphone moving problem)
I have been trying for several days now to set up the correct behavior of the gyroscope in Unity. I want to make it so that when the smartphone is tilted, the object tilts along the z-axis. I found ...
0
votes
1
answer
57
views
7
votes
2
answers
5k
views
Can I just convert everything in godot to C#
Does godot 3.5.1 support C# fully ?
Like does C# for godot have all the same methods that GDscript has?
I'm asking because I remember trying to learn gamedev a long time ago with C++, I was overwelmed ...
0
votes
1
answer
98
views
Weird Lines in my Unity Android Build
So I've been getting this weird bug in the Android build of this game I'm working on. There are these weird lines that all over the place. As far as I can tell, this is a visual bug. Like something ...
0
votes
1
answer
241
views
How to set GameObject on tilemap through script
In the built in Tile Palette tilemap editor, you can choose a GameObject brush to set custom tile GameObjects. How would I be able to set a gameObject onto a tile through a script?. There is no ...
1
vote
1
answer
95
views
How can I fix this NullReferenceException error while all the references are set to specific objects?
I'm currently working on a boss fight for my game.
My problem is that I keep getting a NullReferenceException error that prevents the boss (named The Smallest Stain)...
0
votes
1
answer
57
views
I want add a piece of code where the game checks if the players velocity along the Y axis is under a certain number
The piece of code I want to write is where the game will check if the player is colliding with anything it will check this by looking at your y vector3 is under a certain number (its like this cause ...
0
votes
3
answers
68
views
Switching states within conditional statements in C#
In the usual Update() of a state (let's call it Attack for simplicity) of an object state manager ...
0
votes
1
answer
38
views
Material going to oposite side in procedural mesh creation
Tried to instantiate this gameobject procedurally, material texture went to the other side:
...
-2
votes
1
answer
115
views
Application.Open URL [closed]
I am developing a simple application on Unity, on a Mac. I am trying to open an URL with the simple command Application.OpenURL on visual studio when it doesn't work : When I start to write ...