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
51
views
Why are the transform game objects moving away from the snail when they are swapping their direction?
I am making a game in which I created a character (main player) and another character(snail). Now the snail will move on the ground, when there is no ground detected it will change its direction. I ...
0
votes
0
answers
30
views
Missing tiles when rendering an isometric Staggered tilemap in Unity
I'm trying to show tiles on an isometric staggered tilemap in Unity, but some tiles are missing. I think the problem might be with where I'm placing the tiles or some floating-point precision issues.
...
0
votes
0
answers
16
views
How to stretch a cylinder when dragging with a Ray Interactor?
I'm making a VR game in Unity.
I want to select a cylinder with ray interactor and drag it, and as I drag, it should stretch.
This is the code I have currently for 2D:
...
0
votes
0
answers
22
views
why the car doesn't rotate with circle gameobject that the car is on to that
I have an issue with rotating objects with a circle that I create like this:
I'm going on that but the car doesn't rotate with the circle rotator.
Here is the rotator script that might help because I ...
2
votes
1
answer
160
views
Character controller that can handle sloped terrain and boxy ledge traversal
I am working on a character controller for a 3D platformer in Unity. I cannot find an approach that satisfies me.
I have experimented with these approaches in order to learn about their virtues and ...
0
votes
1
answer
122
views
What is the general technique of optimizing a game's lag by updating thousands of mesh vertices using DOTS parallelism?
*Edit: I finally figured out after some profiling that the problematic code was not actually the ones part of ECS, but this line over here:
...
0
votes
0
answers
27
views
Follow camera is not turning when the followed object turns
I need a camera follow script to chase a moving ball. I've attached the script below to my camera, but when the ball turns left and right the camera does not turn
...
3
votes
0
answers
44
views
How can I create good looking sprite color stretching metaballs?
It has been 8 months I've been working on my metaball algorithm an the final technique I am trying out is writing magnets to which the sprite mesh edge vertices will update its position to, after ...
3
votes
1
answer
484
views
How do I instantiate a scene and change properties on it in C#?
Using Godot 4, following a tutorial but the tutorial is in GDScript. It is hard to find one for C# so I am trying to convert it as I go.
I made a scene called Coin and I have a scene called Main which ...
0
votes
1
answer
43
views
Unity's Camera.ScreenToWorldPoint is apparently "missing", what could be the cause?
I have a small Unity plugin project set up (working on fixing a broken mod), and the Camera class seems to be missing a method. I've added Unity dll assembly references, and everything is working ...
0
votes
1
answer
312
views
How do I configure Godot 4.1.1 to use Rider as the IDE for C#?
I can't find out how to do this. I've installed the godot plugin into Rider.
I found two tutorials, one says to open Godot, and go into Project Settings and find Mono and change some settings. However ...
0
votes
1
answer
46
views
How do I properly use Entities and ECS in a current project that uses MonoBehavior?
I have a class called SpriteMeshModifier, which is a MonoBehavior. Since the rest of my script depends on this class being a MonoBehavior, I have trouble deciding how to translate the bulky updating ...
0
votes
2
answers
82
views
How do I optimize computations for multiple game objects(>1000)?
It has been 8 months I've been working on my metaball algorithm an the final technique I am trying out is writing magnets to which the sprite mesh edge vertices will update its position to, after ...
3
votes
1
answer
73
views
How can I check if `call`, `callv` failed
In Godot, how can I check whether e.g. Call(...) or Callv(...) succeeded or failed?
By failed I mean due to e.g. missing method, ...
0
votes
0
answers
89
views
Resolve dependency between two installers in Zenject
Im trying to implemet dependency injection in my Unity project by using Zenject. I have two installers. The first one is Monoinstaller who is responsible for injection and creation of scene objects, ...
0
votes
1
answer
91
views
How to use Camera.cullingMask to selectively render certain objects?
The documentation of this method doesn't provide any examples of implementing it. I don't understand how it works or even how I should use it to only render particular objects while not rendering ...
1
vote
1
answer
40
views
Instantiate prefab behind moving player
I'm trying to instantiate a bomb prefab behind the player.
The script below works fine when the y rotation is 0,90,180,360. The bomb is instantiated behind the player.
But for other angles, the bomb ...
1
vote
1
answer
22
views
Isolating a mesh so it doesn't interact with Raycasts in Unity
My problem is as follows: I have a a convex hull of some points. Given a point that's outside of said convex hull, I would like to find the closest point on the convex hull.
To that end, I have a ...
0
votes
1
answer
36
views
Making contributions to a Unity project without having Unity editor installed
I'm interested in setting up a small Unity open source project so that non-Unity devs can contribute.
I would limit their involvement to making a small change to only one script, say adding a new ...
0
votes
0
answers
136
views
How to combine 2 splines from different spline container in unity spline 2.3.0?
I'm working on with Unity Spline 2.3.0, I realize that the splines cannot be touch and combine with other splines that exits in different spline container.
Is there any way to connect them?
I tried to ...
0
votes
0
answers
26
views
Stitch meshes with different level of detail
I have an implementation for generating a mesh using marching cubes with different levels of detail.
The issue arises when transitioning between meshes with higher vertex density (smaller scale meshes)...
0
votes
1
answer
85
views
The bottom of the player capsule collider is going into the ground box collider
The bottom part of the player capsule collider is going inside the ground collider. I am using a raycast for detecting whether the plauer is grounded; an object (sphere) that is present on the bottom ...
2
votes
1
answer
154
views
Why does Unity have no official gameplay framework?
As a generalist developer, I have made many server and backend apps and also client-side UI apps. Most of these environments have a certain architecture. For example, in most backend apps, even in ...
0
votes
0
answers
45
views
How to change the locomotive status from moving in a spline to moving in the next spline when it meets the next rail?
I want to make a train that can move in a curve. I have downloaded a Train Spline Walker unity package.
That package can generate a spline, and the train's locomotive will move in the spline with a ...
0
votes
1
answer
54
views
How to Constantly Apply a Force to a Rigidbody Within a Coroutine?
For my game, I am trying to write an enemy behavior script, where the enemy walks forward for 1 second, then stands still for 1 second, then walks forward, stands still, etc. To implement this, I have ...
0
votes
1
answer
50
views
How to make a moving GameObject push a CharacterController smoothly?
I have a GameObject called Player with a CharacterController component attached that has the following settings.
Player also has a script called PlayerController ...
0
votes
2
answers
108
views
Player double jumps immediately with a single press when using new Input System
I am making a 2.5D runner game and I want to switch my input from the legacy Input Manager to Unity's new Input System package.
I am facing a problem when I'm trying to implement the double jump when ...
2
votes
1
answer
436
views
Why can't I access my custom signal under the SignalName subclass when trying to emit it?
I have recently decided to start learning Godot after previously having experience with Unity, and am continuing with C# as my primary scripting language. While everything else regarding signals seems ...
1
vote
1
answer
114
views
Efficient Queries in an archetype-based Entity Component System
I am currently writing an archetype-based ECS for learning purposes. What I noticed is that my current implementation is incredibly slow with large amounts of archetypes.
Each of my queries iterates ...
2
votes
0
answers
89
views
How to get wave height of a gerstner wave made in shader graph?
I have followed a gerstner wave shader graph tutorial. (YouTube Tutorial)
I am now trying to implement buoyancy by attaching the following script to a gameobject. (YouTube Tutorial)
...
1
vote
0
answers
20
views
Move a non-convex polygon's outline inwards?
The polygons are small 3D parts of a quasi sphere centered in the origin and a solution that works in the plane can easily be made to work in this world.
I tried to move the outline inwards by using ...
0
votes
0
answers
56
views
StarterAssetsInputs OnLook is not triggering in Unity New Input System
I have StarterAssetsInputs script which based in new input system but it's onLook event is not triggering at all. Reamining functions like onSprint, onJump are working fine. But unable to find why ...
3
votes
1
answer
105
views
How would I generate mipmaps for a 3D texture in Unity (at runtime)?
I have been trying to create a voxel cone tracer for Unity (in Universal Render Pipeline 16).
I have this (unoptimized) C# code that turns the [CubeScale] area around 0,0,0 of the scene into a 3D ...
-1
votes
1
answer
173
views
The Random.Range function isn't activating when I call it. How do I get the function to work properly and call from a range of numbers?
As you can see, I'm attempting to set the random prey integer to a number within a random range like so:
randomPrey= Random.Range(0,10);
As I type the code out the .Range doesn't turn yellow and the ...
1
vote
1
answer
109
views
How do I make an interactive visual indicator in Unity?
I have a pad I interact with in my game. How do I make a visual indicator like the one shown in the attached GIF? You see that there is a circle that appears on the tablet showing where the user is ...
0
votes
1
answer
68
views
0
votes
0
answers
35
views
My sprite rects are flipped vertically in Unity Sprite Editor after being processed by code
I'm currently trying to process an Adobe Animate XML file with a Unity editor script, and I'm a lot of the way there, my parsing is complete, and I'm able to get some form of output, however the ...
1
vote
0
answers
78
views
How to get OnTriggerStay2D working?
I am trying to make a flamethrower weapon for my player character. I am using a system were I can change between weapons, and every other weapon works perfectly. The flamethrower is able to turn on ...
0
votes
0
answers
32
views
OnServerSceneChanged not executing
I've been trying to make a multiplayer game with mirror networking. The Network Manager works correctly when it comes to changing the scene, but the ...
0
votes
1
answer
59
views
My Update method is shown as unused, yet I'm coding within it
I'm doing a game lesson to get basic player movement working using Unity "Lesson 2.1: Player Positioning". I started with creating the public variables and getting the axis and the ...
0
votes
0
answers
75
views
Scene transitions to Game on host, but not on player client
I've been following Mirror tutorials on Youtube, where there was a transition between a lobby scene and a game scene, I wanted to add a loading scene inbetween them. The issue is the game transitions ...
0
votes
1
answer
99
views
How to make enemy turn to face the player while attacking?
I need help making this code work. It is made for the enemy AI to move and patrol, chase the player and attack the player.
The problem is when it starts to attack the player, then the player can move ...
1
vote
1
answer
335
views
Intellisense broken after installing Unity VSCode extension
I didn't use VSCode since two weeks ago. Today, I opened my Unity Project. VSCode updated some extensions and unhappily, Intellisense doesn't work anymore. I didn't change VSCode settings — all ...
0
votes
2
answers
51
views
How to keep an object that rotates around another at the same height when the radius changes?
In my game, I have one object that rotates around another using transform.RotateAround, and I need to change the radius of its orbit.
The behavior now is that the ...
0
votes
0
answers
67
views
GameObject getting stuck on wall
I am making a simple character controller. Whenever I continuously walk into a wall, gravity just stops working. For example, if there is a wall in front of me, and I jump and walk into it while in ...
0
votes
0
answers
46
views
How to fix the flag bool variable become null and never stop the coroutine?
The script is attached to some objects and in another script when checking distance, I'm starting the blinking and then should stop the blinking. but it's never got inside the stop method because the ...
0
votes
0
answers
30
views
How to make each waypoint individual blinking colors when the camera is reaching the waypoint?
The main goal is to make each waypoint blinking by changing colors when the camera is reaching the current waypoint.
The script and post are a bit long so I will put the whole script and then explain ...
1
vote
1
answer
146
views
0
votes
1
answer
90
views
Store and call multiple functions consecutively
I am looking to create a "stack" of functions that I can call at will. In my game, multiple events can trigger at the same time. These things should not be shown at the same time however, ...
0
votes
1
answer
42
views
Why is rotationAngle not taking effect when changing it in the inspector?
I want to make it so that, when I'm changing the rotationAngle Range slider in the inspector at runtime, it will change the transform rotation angle, but it's not ...