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
0 answers
6 views

I want to change the tint of my panoramic skybox for daylight cycle

So i am trying to create a daylight cycle, where it switches between two panoramic images. The change happens slowly one over 2 minutes and the other over 3. During this the fog and light changes ...
0 votes
1 answer
20 views

Unity shader invalid subscript worldPos

I am trying to write a shader for Unity that replicates Splatoon's painting system, but I cannot get the shader to compile. It has an error on line 41 stating invalid subscript 'worldPos' at line 41 (...
9 votes
3 answers
18k views

How to decompose sprite sheet

I have a lot of spritesheets that are poorly formatted that I want to decompose, or split out into many small images, one for each sprite. If I can do that, I can use my custom texture packer tool to ...
0 votes
2 answers
1k views

Things not appearing in front of canvas (follow up)

Follow up/related question to: Things disappear in front of Canvas I'm having a very similar problem, where things are not appearing in front of my canvas. This time a particle system. I have tried ...
0 votes
0 answers
27 views

How do I repeatedly change the colors of a list of cubes in run time without causing a bottleneck to my fluid simulation?

I am coding a 3d fluid simulation. I want to render each cell of the simulation grid with a cube, so I have a grid of cubes. Each cube has its own color, and the colors are stored in a compute buffer. ...
2 votes
1 answer
3k views

Send an array of struct to compute shader

I am using Unity to send two types of data to the Compute Shader: A struct: struct Flock { public Vector3 position; public Vector3 velocity; } And an ...
1 vote
0 answers
23 views

My Monogame Android game fails to launch on Release build, failing to find ContentTypeReader

Today I struggled with the problem that appears on building my Monogame Android game with Release option. On Debug, everything is OK, but for some reason my game crashes on launch with Release build. ...
0 votes
1 answer
27 views

Why does a numeric input field appear in my Unity event when it doesn't in the tutorial?

I was making a game main menu by watching a video online. In that video, while setting the volume Slider, after adding the coded script in the On Value Changed section and selecting ...
0 votes
2 answers
45 views

2D drag and drop dynamic rigid body spinning out of control in Unity

I'm trying to make a 2d game that involves dragging and dropping certain dynamic physics objects (like squares) and I am a beginner. I need it to look like the rest of the object holds a weight when ...
0 votes
1 answer
40 views

RigidBody floating in th air

I added a death animation among some other things in case of death. But after playing it the player is airborne, so I might need to change the pivot. But I'm wondering if this can't be done with some ...
0 votes
0 answers
40 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 ...
0 votes
0 answers
38 views

I am trying to move a sphere along a curved path made using spline. The problem i am facing is that the ball's velocity when i apply torque is less

I am trying to move a ball along a curved path using torque on the rigid body. The problem that I am facing is that the ball's velocity when I am applying torque is really less, it moves really slowly ...
0 votes
1 answer
30 views

Weird behaviour with SpriteBatch.Draw in MonoGame

I'm creating a rhythm game. I'm trying to move automatically Notes from upside but something went wrong. Notes just stuck. Below is code, thanks in advance for help because I don't understand what I'...
0 votes
0 answers
54 views

Why do I have to freeze my player's x and z rotation to make my player movement work and why does my camera stutter when colliding with things?

So I have an empty object called player with the PlayerMovement script and a rigidbody. I have the main camera and player visual as childs of it. The movement works ...
0 votes
0 answers
29 views

How can I check if the rigidbody is moving

The problem is that rb.velocity probably returns too small values ...
0 votes
1 answer
41 views

Tilemap.SetTile results in no visible change in build

I have an issue with how the Tilemap works in build, using version 2022.3. I update my Tilemap with Tilemap.SetTile(Vector3Int pos, null) and it works just fine in ...
3 votes
2 answers
919 views

Efficient 2D grid overlay on tiles without each cell being its own GameObject

So for my game I need the ability to add a grid overlay over my tilemap. Now I don't think that making the grid with each cell being its own GameObject with some SpriteRenderer would be hard to do but ...
0 votes
2 answers
65 views

Normalize an angle in unity

How can I normalize angle between min value and max value? like normalizing -1136316.78186234° between 0° , 360° or between 180° , 360°. Node: for now I'm using double value as angle. Thanks for ...
3 votes
1 answer
657 views

Create context menu in Scene view

I created some MenuItemfunctions for navigating, which are currently displayed on the menu toolbar. The C# code: ...
1 vote
3 answers
2k views

Instantiated object not tracking collision

I have an issue, and I'm not sure why it's happening. I have a prefab that I've built in a colour-changing game. It has the following: Four 2D objects that if they collide with the player (2D ...
1 vote
1 answer
77 views

Octree as struct not class

I was wondering (as I could not find any implementation online), if anyone here would have an idea of how to create an octree as a struct and not a class. The problem is that Octrees are usually ...
2 votes
1 answer
31 views

Deleting components via OnValidate script while in editor

I want to create different types of platforms for my game, and they are currently all in different prefabs. This works fine, but it is just taking so long to search for the prefab, dragging it in, and ...
0 votes
0 answers
45 views

Rotating Towards the Anchor Point while Swinging

So I've been working on a Spider-Man like game for my company and I need some help with the web-swinging. Specifically, rotating in the character in the direction of the anchor point so the swinging ...
0 votes
1 answer
767 views

How can I create a pressure pad in order to open a door?

I'm making a 2D platformer with Unity and I'm trying to create a pressure pad to open a door. I want the door to open when the player is on the pressure pad and close a few seconds after the player ...
0 votes
0 answers
42 views

Issue when making the player face the direction it's currently going

I'm trying to make the player face the direction it is going, not facing up & down but only on the X & Z axis. Currently the player keeps facing only one direction, no matter which direction I'...
0 votes
0 answers
15 views

How to implement 3rd person animation with acceleration from walk to run?

I am new to Unity and I am using dr Penny de Byl's lectures on Unity. I am trying to use a Mixamo character. I downloaded a character with skin as an fbx file, and also added some character movement ...
0 votes
1 answer
35 views

Weird behaviors with transform.LookRotation when looking at position+Vector3

I'm working on a character controller for an isometric retro shooter. However, when making the character rotate towards where they are moving, I encountered some issues. The character doesn't fully ...
1 vote
4 answers
5k views

Tab between input fields

I am new to working with Unity3d, I need to navigate between several inputField, for this I have looked at the solution that is in: tab-between-input-fields, but ...
0 votes
1 answer
603 views

Calculating position to position B with speed

I am trying to find out a formula that calculates the actual position of a player using his speed and a destination position. These are the informations I have: Vector3 (X,Y,Z) : Current position ...
1 vote
1 answer
101 views

How to generate a series of checkpoints randomly along a 2D line

I was wondering how I would go about generating a series of checkpoint gates along a 2D line in my game. A bit of background, my game is a 2D reinforcement learning car driving simulator, I have a ...
0 votes
1 answer
485 views

How to get reference to board tile object another game object is sitting on?

I am trying to get reference of the object underneath my Player. I don't know if I am approaching this correctly. Right now, I have a player simply put in the scene, like this: Then I am trying to ...
1 vote
1 answer
64 views

What is the simplest way to enforce/remind people to set a variable in a subclass when the code is dynamic?

I have a base class for Abilities. This is a point and click game, therefore I have Click, Hold and Drag subclasses. What I need to do is remind myself to set the player's AI state to Ability when it ...
0 votes
0 answers
29 views

Inconsistent results from ApplyCentralImpulse with RigidBody2D

I'm working on a 2D top-down game using RigidBody2D for the player and enemies. They're bouncing and moving (using ApplyCentralForce) and detecting collisions just fine, however now I want to add a ...
6 votes
2 answers
586 views

Collision detection problem in XNA4/Monogame

I have been trying to get 3D collision detection working for a while and I think (hope) you people can help me. For my project I have created a 'sprite3d' kinda class which is called ...
0 votes
1 answer
648 views

How to check if one object's local bounding box contains another

I am currently trying to check whether the first object contains a second. I first tried to use the bounding box, but it is defined in world space, so it is not working with my rotated cubes. Then I ...
0 votes
1 answer
49 views

Call to Random.Range() is breaking my prefab instantiation

This is for a simple sidescrolling game. I want to have it so that when an enemy is killed, it has a chance of dropping a health collectible for the player. I wrote a separate simple bool method ...
1 vote
1 answer
71 views

Rotating around Wall Corners while Climbing

So I've posted here before regarding a Spider-Man like game that I'm working on. I'm facing another dilemma now. I want to rotate the player around the edges of walls. So far, I've implemented a ...
2 votes
1 answer
473 views

Trouble GamePad input on iOS but works perfect on Android

I am having trouble getting input from on iOS devices (iPhone 6 Plus and iPad). Here is my code, ...
0 votes
2 answers
56 views

Getting the Player to Face Movement Input on the Z-axis

I'm working on a Spider-Man like game and I've run into a problem. Whenever I'm near a wall and press the w key, the player starts climbing the wall. But when on the wall, I want it to face the ...
0 votes
0 answers
13 views

How to use a key to stop playing the current animation, and replay it from the beginning?

In my Unity project, I tried to use a key to stop the current animation and immediately play it from the beginning again. I also tried to control the delay before I can press again. The following ...
0 votes
2 answers
491 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 ...
0 votes
2 answers
50 views

Can you somehow use underscore to ignore different results in Unity like you would do with TryParse?

So I may not be the best programmer, but I am not a beginner. So in C# when you want to check if... lets say if its a number or not, but you dont care about the result(the you could write something ...
4 votes
3 answers
6k views

Flip sprite vertically AND horizontally?

In Microsoft.Xna.Framework.Graphics.SpriteEffects there is the possibility to flip a texture horizontally or vertically before rendering. But can one do both at the ...
0 votes
2 answers
479 views

Converting from global coordinates to local coordinates

I am trying to create a Radar/Minimap for the F1 2021 game in C#/WPF. Here is a image of what I am trying to replicate In the image, the white car (my car) will always face the direction it is going. ...
0 votes
1 answer
414 views

Marching cube terrain generated by compute shader gives strange error

I'm creating my own terrain terrain system for Unity using marching cubes but I've run into a problem I'm stumped on. First I'll explain how it works: A compute shader creates an array of points ...
0 votes
2 answers
120 views

Is this enough calculation on server-side to be secure?

I'm a beginner about client/server calculations and relationships (never trust the client), and I would like to know if I did or didn't get the concept right. My weapons are calling this function ...
2 votes
2 answers
62 views

How would I make minimap of racing track where dot follows track progress in Unity?

I would like to show race progress in my UI. My minimap is like sketch below: Blue dot represents progress and red dot is finish line. I would like this to work in UI so only blue dot would move. If ...
0 votes
1 answer
34 views

I am having error CS2012 when trying to run my visual studio code in unity (i am new to this)

I made my first script in Visual Studio and saved it to Unity, however, i get this error: The requested operation cannot be performed on a file with a user-mapped section open. This is my code: ...
0 votes
1 answer
31 views

Null reference exception when adding bodies to a list

So, for conversational clarity/brevity, I have 3 sphere gameobjects, each with their own Rigidbody component. They all have a tag of 'body'. The 3 spheres have progressively larger masses. body1 mass:...
0 votes
2 answers
7k views

Diagonal movement is faster than horizontal or vertical movement. How to fix?

When using Horizontal or Vertical input keys, the the movement is normal. But when trying to move diagonal, multiple keys are to be pressed, and the speed just stacks up. Yes there are many answers ...

1
2 3 4 5
168