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
1 answer
32 views

How to keep gui button original color including the white content color?

This is just a test. The PING PONG button color is in Red and also the START/STOP button start with the Red color. but in the START/STOP button i'm trying to keep the original color and then to change ...
user avatar
0 votes
1 answer
91 views

How to change GUI box background color for each gui button individual?

The problem is at this part, the color is changing the background also for the PAUSE button and not only for the PLAY/STOP button. Before i added this part the PAUSE button color changing was working ...
user avatar
0 votes
1 answer
35 views

Why when changing gui box color ith a color variable in the inspector in run time the color on a gui button is not the same?

When setting the color i'm not using the alpha because then it will not change the color at all and it will be transparent. in this line : ...
user avatar
0 votes
1 answer
23 views

How to use pingpong in the waypoints script?

I tried this : And the pingPong is working but after some times changing the pingpong flag true false many times i'm getting index out of bound exception : The pingpong line that give the exception : <...
user avatar
0 votes
1 answer
25 views

Is there an alternative to Update for continuously spawning an object?

What I did here works, but it looks messy and funny to me. ...
user avatar
0 votes
1 answer
42 views

Attach images via script into array unity

I have 3 objects of Image type in game scene. So I need to attach this 3 objects via script into Image array inside of this ...
user avatar
  • 3
0 votes
1 answer
127 views

Action delegate always return null

I have two separate classes(Tree, Inventory), OnCollision I trigger the Interact function, in which there is an Invoke of an Action delegate event TreeCollected, it seems to always return null ...
user avatar
  • 11
0 votes
0 answers
52 views

When drawing a circle around object the radius is seems to be not accurate. what could be wrong with the circle?

This script is attached to a gameobject with a linerenderer and draw a circle around the object it's attached to : ...
user avatar
0 votes
0 answers
32 views

Finger (Sensor) Shaking Detection

I want to make the user be able to shake a certain object through the phone's sensor. I have drag&drop mechanics now, and I want this shake to be directly related to that mechanics. How would that ...
user avatar
0 votes
0 answers
49 views

(FSM) Detect a change on a variable on Update, and trigger certain State

So, I'm working on a FSM that ticks on every frame. The inner workings can be simplified to this: The user (me) creates the States: ...
user avatar
0 votes
1 answer
50 views

How to create IOS style rubber scrollbar in unity?

I'm looking to create a scroll bare similar to IOS scroll when you load page or something when it lets you pull all the way down but the tension gets higher like it is on spring. How would I approach ...
user avatar
  • 127
0 votes
1 answer
41 views

How do I resume the rotation where it last rotates when it got pause?

...
user avatar
0 votes
1 answer
90 views

Is there a good practice for defining names programmatically?

In my use of Unity so far, I've been defining element names programmatically with classes like this: ...
user avatar
0 votes
0 answers
35 views

Unity Photon doesn't add physics to the second connection

I am trying to make a multiplayer air hockey game in Unity, but encountered some problems. When the first user creates the room, the hockey puck is spawned along with the first player's mallet (the ...
user avatar
  • 101
1 vote
1 answer
93 views

Speed up Reaction-Diffusion simulation calculations in Unity

I'm trying to use Unity Job system to speed up some calculation related to Reaction-Diffusion simulation. The calculations requires 2 matrixes, current and ...
user avatar
  • 117
1 vote
0 answers
31 views

How can I instantiate an object at a certain position?

In my game, the player drives a car and when the car reaches the end of the road, I want a different road prefab to be spawned. I have multiple road prefabs, and want to be able to spawn one when the ...
user avatar
0 votes
1 answer
35 views

Why lookat is working but when using slerp to rotate smooth to look at the same target is not working?

This is the part when i'm trying to rotate the objectToThrow smooth slowly. ...
user avatar
-1 votes
1 answer
28 views

How to destroy just the specific powerup I hit, not all of them?

Creating a game for a computer science class - basically I have a player (cop) who will collide with donuts. When the player collides with a Donut, I want the speed to increase by 0.5 each time. Here ...
user avatar
0 votes
1 answer
27 views

How to not create a new event every time I introduce a new "boss"

I have to create a new event when I'm going to enter a new boss phase when the current boss dies. This works, but I can see this being messy when I'm going to create a new boss each time. Below is the ...
user avatar
0 votes
1 answer
145 views

How to change which monitor is fullscreening a game player at runtime?

I have a Gameplayer window running Unity2020.3.32f1. I'm making an options window to fullscreen the game. I'm trying pull up the list of available monitors to fullscreen the game to. However, when I ...
user avatar
0 votes
1 answer
29 views

Is there a way to not keep creating new events to spawn in my new object each time?

I have an event manager to help to communicate between two scripts. One is for the script of the object itself to pass on the message to the other one which is the spawn manager(you see below). What I'...
user avatar
0 votes
0 answers
22 views

Instantiated game objects go in random directions [duplicate]

I have a script that instantiates projectiles and it is supposed to shoot them in the direction of my mouse. This is my code: ...
user avatar
  • 3
0 votes
1 answer
68 views

Create own texture paint tool in Unity

I want create texture paint tool based not on vertex paint, but on splatmap UV. I already write simple shader: ...
user avatar
-1 votes
1 answer
84 views

Using perlin noise as a procedural voxel heightmap without a texture atlas in Unity

I was creating a heightmap for my procedural voxel world in Unity using 2D perlin noise. I don't want to use anything from a texture atlas, a brown Unity material is good enough for me. The issue is ...
user avatar
0 votes
1 answer
55 views

Method of compressing tile data [closed]

I'm making a game in which a row of tiles may look something like this, in which each block is represented with a unicode char: “gggggggggggggggggggggggggggggggggggtttttttttjjjjjjjjjjjjjjj” So my ...
user avatar
0 votes
1 answer
23 views

Unity seems to be stuck rendering through camera outside of play mode

This may or may not be a dumb question, as I am very new to Unity, but for some reason Unity is rendering through a camera after exiting play mode. I had this issue with another project originally, ...
user avatar
0 votes
0 answers
24 views

How to make an Inspector field accept references to instances of different classes

I have a variable in my Unity script, and I want to be able to assign to that variable an object of one of two different classes; for instance: ...
user avatar
  • 3
0 votes
0 answers
40 views

Best way to draw a tile (a floor) all over the screen?

I wanted a tip, a guidance perhaps to know the best way to draw a tile all over the screen. This tile is a 16x16 tile that should be the floor in my top-down map. I set my resolution to 1280x720 and i ...
user avatar
1 vote
1 answer
51 views

Can't select external script editor in Unity3D

in Unity3D 2020.3.32f1 when I try to select my external script editor via Edit->Preferences->External Tools->External Script Editor the file dialog opens and I try to select VSCode. So far ...
user avatar
  • 229
0 votes
1 answer
76 views

I'm trying to add gun shooting and cooldown into my 2d game

the problem i'm having with projectile is that it spawns on my cursor instead of my gunEnd, it also spawns with no force at all. I'm also having a problem implimenting a cooldown, I'm new to C# so ...
user avatar
0 votes
0 answers
24 views

When changing the radius variable in the inspect at runtime, Why the transform is not moving to the new radius?

Now i'm using the variable radius just to move the transform at the first time when running the game to the radius position and then the transform is rotatearound on the radius. I'm getting the radius ...
user avatar
1 vote
0 answers
9 views

Linking components to local in-project documentation

Unity 2020.3.31f1, Windows 10. Is it possible to use local documentation, e.g. HTML files in the Assets folder of a project, as the Help URL for a component? If so, what path should I put in the ...
user avatar
  • 137
0 votes
0 answers
45 views

Unity - How to spawn hook and have ability reflect to object?

In this game, I'm trying to make a rope with a hook that bounces or reflects the same as the aim direction, so this rope with a hook has max length when reflecting something, basically hook has a tail/...
user avatar
0 votes
1 answer
58 views

More efficient/clean way of programmatically generating and customizing repetitive objects?

I am coding my UI in Unity C# with the UI Toolkit, and as I write more and more my code is getting quite annoying in terms of one particular issue. I find myself repeating many similar lines of code ...
user avatar
  • 207
0 votes
1 answer
29 views

How to scale all meshes of various scales to a unit scale

I have a few objects with different scales i want to make a scene where all objects are scaled proportionally to everything else, something like a normalize function for a mesh. How would I go about ...
user avatar
-1 votes
1 answer
71 views

how do i still get a reference from the game object after it get destroyed?

This is the script from the game object that will be soon get deleted. ...
user avatar
0 votes
0 answers
29 views

Conflicting between single finger and two fingers zooming in unity

I'm trying to rotate around an object using single finger, and using two fingers I'm trying to zoom in/out. The problem right now is there is conflict between both commands, and either of them should ...
user avatar
  • 1
0 votes
1 answer
74 views

Large Armies fight : Looping through a million elements

I'm currently developing my first game. I had the idea to do something similar to the old browser games like Ogame, Travian, etc (with some differences though), and I'm kind of unsure about how to ...
user avatar
  • 1
0 votes
1 answer
72 views

How to give two GameObjects references to each other?

I have two GameObjects and would like both to have a reference to the other. I know this can be done by creating public properties and setting them with Unity's inspector, but my preference is to ...
user avatar
2 votes
0 answers
67 views

How to accelerate car based off of Animation Curve?

I am making a karting game and I want the karts velocity to accelerate based off a curve. This would allow me to quickly iterate different types of cars that accelerate in different ways. I was ...
user avatar
0 votes
0 answers
29 views

Help creating 3d object view with Accelerometer in Unity?

Hi I would like to create a object view controlled by mobile accelerometer so it gives a AR impression like in this video: https://www.youtube.com/watch?v=5A8olJzeAYg. So this is what I tried so far. ...
user avatar
  • 127
0 votes
1 answer
30 views

How do I enlarge my gameobject(circle) in one straight go instead of enlarge it little by little (frame by frame) when hit the collision?

...
user avatar
0 votes
1 answer
79 views

How to rotate the transform smoothly to 0,0,0 using lerp/slerp?

The reason why I need to use a coroutine for the rotation is that the object I throw to the target will move to the target and back once and then when the object return back I want the object also to ...
user avatar
0 votes
1 answer
162 views

Remove material slot via Unity Script

I have a lot of duplicated objects, and I need in editor, not in the game, remove specific (18) material slot. Remove not material in slot 18, but remove slot 18. Manually, by hands, it can be done ...
user avatar
-1 votes
1 answer
28 views

I want to use a number that I got using Debug.Log, and use it later in a game over screen to show a score

How can I save this number as a variable to use in a game over screen? This is my code to get the number public void StopCount () { Debug.Log(disRun); }
user avatar
  • 1
2 votes
0 answers
32 views

How would one make a custom inspector for built-in assets?

I'm trying to see how I could either modify, append or completely override what the inspector shows for a selected built-in asset. Specifically, I want to override what the inspector shows when you ...
user avatar
0 votes
1 answer
84 views

Unity Build is showing GooglePlayGamesManifest.androidlib' is Missing.?

I was trying to build my unity project but it is showing this GooglePlayGamesManifest.androidlib' is missing AndroidManifest.xml file. UnityEngine.GUIUtility:ProcessEvent (int,intptr) some more ...
user avatar
0 votes
0 answers
19 views

why doesn't my spawn manager instantiate after checking the bool from another script?

This is where the bool originated ...
user avatar
-1 votes
1 answer
37 views

How I can solve "Object reference not set to an instance of an object" problem in my code?

It's simple turret rotating code. The problem is when the Player is destroyed by enemies, I get this error message below: "NullReferenceException: Object reference not set to an instance of an ...
user avatar
  • 3
0 votes
1 answer
453 views

Keep aspect ratio on window resize in Unity

What is my problem? I have started a new 2d game project in Unity and would like to allow for resizing of the window by the player. When resizing, I don't want black bars at any of the 4 sides (I ...
user avatar