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
2answers
63 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
1answer
15 views

How to apply brightness/contrast adjustment to a texture's pixels?

I'm trying to use a non-shader method to convert a (single-frame) Texture2D to one with different brightness/contrast. Attempt so far uses: https://stackoverflow.com/posts/15408608/revisions I'm not ...
1
vote
2answers
307 views

Unity Mouse position for weapon wheel

Say i have the following wheel: Now i wish to use the mouse to select weapon by movement: So If mouse is to the left it picks the Sword if mouse is at the top it selects the bow and arrow if the ...
0
votes
1answer
138 views

Managing large amounts of data and processes for an economy management game

I'm making a management game in the vein of Anno or Stellaris, but I'm unsure how to manage all my data efficiently. Short example: the player controls multiple islands. Each island has factories on ...
1
vote
2answers
819 views

RaycastHit2D.normal sometimes giving an unexpected direction

I'm working on a little pong clone and trying to implement collisions using triggers. I have a ball which OnTriggerEnter sends out a raycast from the ball's position towards its velocity. I then take ...
0
votes
0answers
22 views

I can't add the change I made while the game is running to the list?

Node script is shared below. The Node script works fine when I run the game for the first time. However, while the game is running, when there is a change in the map, the list specified in the script ...
0
votes
0answers
16 views

Can't publish app bundle because it can't be installed on Android 12?

I wanted to publish a newer version of my already published game to the PlayStore but it wasn't letting me therefore: "You uploaded an APK or Android App Bundle which has an activity, activity ...
0
votes
1answer
35 views

Serialize List of References

I have a list of object references inside a serializable class, like this: ...
0
votes
1answer
35 views

Clipping speed when turning without using aggressive drag

I have a Unity project in which I want to control a player in a similar way to Source games, and so far I am clipping each input to the speed in the player's coordinates, by using ...
5
votes
3answers
1k views

Pathfinding for a lot of units, mostly random movement

I'm using a uniform cost eight-directional grid as a map, with buildings that represent unpassable terrain - the map tries to simulate a top-down flat city. I'm trying to fill the city with randomly ...
-1
votes
1answer
26 views

Why the transform is never moving and reaching the last fifth last waypoint?

I have 5 waypoints ,each waypoint tagged and named as "Teleporter". The Mover the blue cube is start moving to the first waypoint and then should move between all the other waypoints. but it'...
0
votes
0answers
12 views

Tuples in Unity, or how to store two pieces of data in as a single entity in a sortable list? [closed]

I'm currently trying to figure out a way to store a Vector 2 and an int together as an item in a list, in order to be able to sort a list of destinations by priority (indicated by the int stored with ...
1
vote
1answer
242 views

Translate position from 3D camera to 2D camera

Currently I have 2 cameras, one for viewing the 3D objects (Perspective), and the other camera to view 2D objects (Orthographic). (Also, the view of the camera never intercepts each other.) I am ...
0
votes
1answer
50 views

Should UI systems update naively with events and data from outside, or should they be coupled to some game state/singleton to know to change itself?

I'm making a game in Unity for my game dev course in uni. I hope the question isn't too confusing but I have bolded sort of like a TLDR at the bottom. My level currently has a pregame UI panel, to set ...
0
votes
1answer
174 views

Persisting unlocked characters in Player Prefs

I am working on a character selection menu in Unity. If you have enough coins, you can buy your desired character. Once player buys one, that character must not be locked on game restart, the number ...
0
votes
0answers
13 views

Cinemachine lock on

I'm using Cinemachine for a free look 3rd person camera and a virtual camera for a lock on cam. I already have switched Cinemachine brains and movement types done, but I need the player to face the ...
1
vote
1answer
77 views
2
votes
1answer
33 views

OpenTK immediate mode on net core doesn't work?

I have some old code that i imported into an OpenTK C# application running on NET 5.0. The rendering uses old fashioned immediate mode and it works on my current computer but nothing renders in the ...
0
votes
1answer
38 views

How to add delay to the moving objects?

Now all the moving objects are moving like a group to the same target. I need them to move to the same target but with a delay between them. The first object start moving to the target after X seconds ...
0
votes
0answers
31 views

Unity code design - Events

I am aiming to create a Unity project with a code structure similar to ECS. I want the code to be consistent, easy to integrate extend and expand if multiple developers will work with it. By that I ...
1
vote
1answer
451 views

Unity, hold down right mouse button to turn the camera

How would I use my right mouse button to turn a player character in Unity, while only turning in the direction and speed of the drag? The game is 3D and you should hold down right click and drag to ...
0
votes
1answer
34 views

What is the best way to present "rate this app/game" with unity/c#?

I want to give my users a chance to rate my game at the Google Play Store. How can I achieve this on Unity/C#? I would like users to be able to rate instantly inside the game window without being sent ...
5
votes
2answers
5k views

Smoothing Heightmap Data

I've made a Heightmap Generator that creates island heightmaps like in this picture: I am dividing the grayscale ( 0 - 255 ) into 4 diferent parts ( water, sand, gras and forrest ) and after coloring ...
0
votes
1answer
14 views

Clarification of functionality of Vector2.MoveTowards method

In Unity's documentation for Vector2.MoveTowards, they assign a two variables, "speed" and "step". "step" is simply speed * Time.deltaTime. Why is this step variable ...
0
votes
1answer
307 views

Clamp GameObject Into Isometric Camera Viewport

I'm using the next code to move an objecto into an isometric projection (30/45) ...
0
votes
1answer
26 views

Slowing down mouse movement in Unity

I'm using the game to control electronics. I use the following code to determine the location of an object (the location is used to perform calculations that are sent to the electronics) ...
0
votes
2answers
7k views

Android Unity black screen on game start up

Squishing bugs on my first game currently, came across a problem I'm not sure what could cause. When the game is launched there is simply a black screen before even the unity logo shows up, the ...
0
votes
1answer
662 views

When to destroy Google AdMob InterstitialAd object?

There are a few answers on this question but they don't give a satisfactory answer. I am using a singleton AdManager class that persists throughout the game. I am not sure if I should destroy the ...
0
votes
1answer
287 views

Unity - adding camera constraint to prevent the player from seeing beyond the scene

Like the title says, I'm after some kind of constraint for the camera to prevent the player from seeing beyond the scene and seeing the Skybox. I came across the code to add a ...
3
votes
2answers
691 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
0answers
27 views

How can I fade in out object/s?

In general the main goal is to teleport between teleporters with fade out/in when teleporting. but for testing the Fade I call the Fade method once in the Start : ...
0
votes
1answer
20 views

How to change size of a SINGLE tile on a tilemap at runtime?

I'm having trouble figuring out how to change the scale (size) of a single sprite (tile) on a Unity Tilemap. In the game, I place trees as tiles on a tilemap, and when they grow over time, I want to ...
1
vote
1answer
203 views

How to stop my cube collider when it hits another collider using Transform.Translate?

As we know, Transform.Translate() ignores collisions. What functionality do I need to add to my code so that when my collider hits something, the physics system ...
1
vote
1answer
53 views

How can I send different contoller input to the different player avatars?

My apologies in advance for the vague question, since I don't understand the problem well enough to ask in finer detail. I want to create a multi-player Unity application using the Oculus SDK. Let's ...
0
votes
1answer
83 views

Zoom into character upon collision

When a character collides with an object in my game, there is a slow motion effect. That's coool, but how would I zoom into a sprite when it collides with another object? Here is my code currently... ...
0
votes
1answer
74 views

Best practice for getting references to gameobjects unity

When structuring the script to control a gameobject with several generations of children underneath, I gather from one of Jason Weimann's videos that it's a bad idea to use the string based methods to ...
1
vote
1answer
42 views

Unity: Editor only monobehaviour (not gameobject!)

I'm well aware of the EditorOnly tag on gameObjects. However, my question is slightly different: I have a large number of gameobjects in my scene that only mark a spot, i.e. I only care about their ...
0
votes
1answer
15 views

Can a BoxCollider 2D be a child object of a Rigidbody 2D ? (as it's not working)

I tried to find a solution before and asked elsewhere but couldn't find the exact same issue. I have a parent game object that is a Rigidbody 2D, and this object has children that are BoxColliders 2D. ...
2
votes
2answers
84 views

How to program different types of monsters

I'm working with a group of programmers and I'm trying to program different types of monsters in Unity. I want to make it so that all the monsters have values like attack power, attack speed, moving ...
1
vote
0answers
53 views

Odd behaviour from parallax

First of all I'm going to say that I'm not trying to blow my own trumpet or anything but usually I'm able to figure this stuff out on my own. But as for now I'm fully stumped. Maybe I'm having a mind ...
1
vote
1answer
107 views

How to scale player as they travel between 2 points

I'm doing a VR Project where the player walks down a hallway. The player starts with a size of 10 and is supposed to scale down to a size of 0.5 (well the GameObject in which all the player stuff is ...
0
votes
1answer
88 views

How to create 3D area mask?

I have two cubes, one parent and one child. I want to use the parent's cube mesh as a mask for the child cube. I want to make visible only the part of the child cube that it is inside the parent cube. ...
0
votes
2answers
63 views

Create buttons in the editor - Unity3D

So I've seen people do stuff like ...
0
votes
1answer
30 views
1
vote
2answers
718 views

Creating animation by script with animation assets

I'm very new to Unity (not to C# and programming as well) but I managed to achieve some goals very fast. But some concepts I still don't get in their full aspects. I'm developing a small multiplayer ...
0
votes
1answer
49 views

Draw LineRenderer gradually, rather than all at once

I'm drawing a line with a LineRenderer. It works, but now I would like it the line to be drawn gradually, instead of appearing all at once. How can I modify my code ...
-1
votes
1answer
273 views

How to make random spawn objects in unity 3D

I created an infinte runner game. I need to make random spawning obstacles ON 3D. How do I randomly spawn prefabs on the X axis using a C# script?
0
votes
0answers
13 views

When using animator state with parameters conditions type trigger it's working only for the first but why it's not working for the second?

In the Animator Controller I added a new state with animation the idea is to make a smooth transition between the idle to the new state animation. The first transition is using in the conditions the ...

1
2 3 4 5
155