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
-1
votes
1answer
31 views

how to set the first color of the list in the sprite

...
1
vote
1answer
124 views

How to draw a diagonal sine wave line renderer

I'm trying to use a LineRenderer component to draw a sine wave from point A to B and I'm using mouse position. However what I did so far is not working as expected, ...
0
votes
1answer
17 views

cursor cannot active and deactive when click ui

I have a player with a third person character controller component. i have a problem with the cursor lock it hide and cannot click the ui button. i already try some coding but error. SORRY Im very2 ...
1
vote
3answers
95 views

What is the purpose of the macro UNITY_EDITOR?

I found on a tips guide in Unity that I can do: #if UNITY_EDITOR do_something() #endif And do_something() will only be ...
0
votes
1answer
20 views

custom mesh object orientation is not correct using

I am making a custom mesh with the help of Traingulator script. At runtime, user can click and and generate a point then mesh creation start. Here is the way i am getting user input. ...
-2
votes
1answer
29 views

How can a NamMeshAgent be configured to always look towards its next path position, but never move there?

I'd like to have something like an on-screen panel that appears in the direction that you are supposed to go. The panel is a NamMeshAgent with a speed of 0. I was hoping something like this would ...
0
votes
0answers
26 views

Getting Prefabs gameobjects with tags from folder

I have some problems. When I refreshedd codes or tags on projects. This code does not work. When I rechoose tags again on prefabs, it starts to work again. ...
1
vote
1answer
37 views

How can I automatically pause my timeline at a specific time code?

I want to setup a way that the timeline will pause at a particular time/frame. I have tried this, and it doesn't work: ...
3
votes
3answers
294 views

Unity Round(Circle) Buttons

I have been using unity and C# scripting now for the past 2 or 3 weeks. So yeah i am very new to unity and C#. I wanted to know if there is a way to make a round(circle) button without using the ...
0
votes
0answers
61 views

How can I make the screen scroll only when the character is close to the edge?

On the internet, I saw videos and tutorials about screen scrolling. But those only show how to keep the player always in the center of the camera. I want my camera to scroll over the level, following ...
-1
votes
1answer
31 views
1
vote
1answer
29 views

button thumbnail slider effect unity3D

I am trying to make this effect for buttons. i.e the middle one is bigger and is selected. the buttons can be moved left or right by swapping with finger. Does anyone have any idea how to do it?
0
votes
1answer
104 views

can't make my unity character move

so I'm starting with Unity , I followed the john lemon tutorial , and I wanted to apply what I learn on a model on my own coming from blender. Everythings works , animation , rotation , but not ...
0
votes
1answer
55 views

How to calculate IsGrounded more effective?

...
0
votes
2answers
38 views

Custom FPS Controller in Unity 5.6.6f2 not letting me look up or down

Due to the FPS Controller seeming to be broken in Unity now, I started using a custom one by kinifi on GitHub. For some reason though I can't look up or down. I removed the Main Camera so it should of ...
0
votes
1answer
28 views

Non monobehaviour classes not working properly

I am trying to make a deck of cards in c# for use in Unity. But when i planned it I didn't think that 'Deck.cs' or 'Card.cs' would need to inherit from Monobehaviour. I have written 3 classes (one is ...
0
votes
2answers
36 views

Pathfinding with direction considerations

Consider the following road network. The car (orange) needs to get to the red circle. It drives on the right hand side of the road and is initially facing down. The shortest path is the blue one. But ...
0
votes
1answer
43 views

Ordering a List doesn´t work. - InvalidOperationException: Operation is not valid due to the current state of the object

I have this method. It´s for ordering actors and only displaying the ones which are in direct line of sight with the player. ...
1
vote
1answer
56 views

Player doesn't move smoothly, when trying to follow position between cursor and player

When my player moves, moving the camera looks like the camera is teleporting to the player, and then after loading teleporting again. I want to make it move smoothly. When the camera is following the ...
1
vote
0answers
37 views

Implementing a scrollable Panel in XNA/MonoGame

I am trying to create a scrolling Panel for my game. The code I've shown below works but there is a problem. I read Andrew's answer here and decided to implement the scrolling effect by using a ...
0
votes
2answers
51 views

How to modularly call a script based on parameters within the script?

I am coding an interaction system in Unity that does things based on whether the player taps interaction, or holds interaction. Each object holds their own scripts of how a player can interact with ...
0
votes
1answer
76 views

Sebastian Lague 2D Platformer Controller 'Continue' Problem

In episode 10 of Sebastian Lague's "[Unity] Creating a 2D Platformer" series, he creates a jump through platform by using "Continue;" in his vertical collisions script. This worked great for a jump ...
1
vote
1answer
67 views

How to fill a 2d array with elements of a 1d List

I have a 2d array for 'Slots' in my inventory screen (slot width: 150px; total slots is based on width and height of inventory panel currently at 1500x600). The slot holds a reference to the ...
2
votes
2answers
177 views

How to disable BoxCollider2D on all prefabs?

I made a prefab that when hitting one object will disable it's box collider2d and enable it after hitting a different object. It works find when there's one prefab, but when there's move, it only ...
0
votes
0answers
18 views

Error comparing Input.GetTouch () .phase with TouchPhase.Began

In the update method I'm using unity's touch, as you can see in the code. ...
0
votes
0answers
18 views

how to move the rect transform by mouse drag

I am trying to do a slider in the UI with the mouse, I want to move the rect transform right side when I drag the mouse right and vice-versa. I tried but it didn't work please help me thanks in ...
1
vote
1answer
36 views

Smooth shading along edges with duplicate vertices

On this generated mesh, I have sharp edges, because each square has duplicate vertices separate from its neighbours. I can't remove the duplicate vertices because I'm using them to provide unique UV ...
0
votes
1answer
93 views

Destroy chunked block like Minecraft

I am trying to do a Minecraft-like game (like every one have already tried I guess) and i went across the problem i expected: lag with world Generation. I did lot of searching but i can I tried to ...
1
vote
3answers
88 views

Unity, check if all GameObject tagged are destroyed

Hello im a total noob so please dont blame me. So, I have this code but I cant find a fitting answer on how to check if everything tagged "Target1" is destroyed. Most of the answers are either ...
0
votes
0answers
67 views

Update position using animation curves

Implementing the suggestions from this answered question, I am trying to move my player according to the animation. To do so, I am adding the transform.position property to the animation and then, ...
3
votes
2answers
69 views

How can I play a particle system only when it's visible?

I am making a game and it has a lot of particle systems in it as special effects, and all of them are supposed to be playing at the same time, but doing that will be heavy on the game's performance, ...
0
votes
1answer
29 views

Can't Transform.SetParent in Unity

i have a problem that i don't understand why is happenning and it's driving me mad. I'm trying to code a script to put the player in the car by disabling the third person controller and then Transform....
0
votes
0answers
22 views

White shadow map

I am implementing the shadow map with OpenTK and c#, I do everything as expected but I always got a white shadow map if I render it to a quad. First I initialize the frame buffer object ...
0
votes
0answers
22 views

Restrict Trajectory on Z axis

I have a cube which I select on mouse and point out the location to throw the cube with trajectory dots. The code is working fine, but I need to restrict the trajectory dots position on z axis so the ...
0
votes
1answer
73 views

How to Set PlayerPrefs.SetInt?

playerpreferance.setint problem I am develop one game.In this game 15 levels. I am face this type of issues when send one level score into second levels. I am used player preferences in start() ...
0
votes
0answers
31 views

Using different referenced libraries for different build configurations

I use MonoGame Content Builder and I have some Content Pipeline Extension libraries referenced in the Content.mgcb file. They are referenced like this: ...
1
vote
1answer
37 views

Unity 2d Animation from spritesheet: How can I move the character according to the animation?

I am trying to implement an attack animation that should end up in moving the player by some distance. The animation would be something like this: As you can see the position of the player should ...
0
votes
1answer
23 views
0
votes
1answer
35 views

Unity Third Person Controller Camera-Relative Script [duplicate]

I'm an newbie in game developing. So i have a script for a camera that i attach to the player. I was wondering how to make a Third Person Controller with WASD controls that moves in the direction that ...
2
votes
1answer
59 views

How to stop switching between paths to a moving target?

I've noticed after implementing A* pathfinding into my game, that there is exploitable/unrealistic behavior that goes on when the player moves between two nodes that alter the path of the AI trying to ...
1
vote
2answers
59 views

How can I make a look around effect of the player some kind of cutscene?

I want that at some point in the game the player will be looking over the view out of the window. So I added a new Camera and positioned the camera close to the window. Then using a small script I'm ...
0
votes
1answer
29 views

Unity: Saving scene after using script to change object positions

I have a c# script which makes some edits to object positions in the editor. It does this by reading some values from a csv file and then changing the value of ...
0
votes
1answer
122 views

WebGL Freeze for some minutes after loading asset bundle

I have to Load/Unload models from a specific URL based on player position. For this reason I am checking player position from model and then load/unload related piece of model in a ...
0
votes
1answer
49 views

Detect left and right movement of sprite

I have a sprite of ball which moves when a player tap and holds the ball and move finger on the screen. I have a attached animations on it. straight, left, right and when the ball hits something. ...
0
votes
0answers
12 views

Applying a custom attribute to Input Field - Unity 2018+

Is there a way I can apply custom attribute to an Input Field in Unity. It says something about not able to cast the property(in attribute drawer class) to InputField
0
votes
2answers
182 views

Camera.main is not what the user sees

I'm developing (or rather butchering) plugin for Rust, which was build in Unity, and I need to create a targeting system. Unfortunately I got stuck on ...
0
votes
0answers
17 views

How to inflate deflated chunks from .mca files in c#?

Using this site as a reference https://minecraft.gamepedia.com/Region_file_format, I am able to parse the first 8 kb of a .mca file and extract the chunk/section index. I then try to decompress the ...
1
vote
0answers
85 views

C# 2D game collision detection huge problem

I'm making my first game using C# and Monogame and I have a huge problem with collision detection. The entire code is in a link below: My game code So, I use Vector2 to keep position and dimensions ...
1
vote
1answer
122 views

Draw trajectory arc predictor in game

I found this tutorial on youtube and it works pretty well, but I want to add more to it. How can I draw a smooth arc path in the game view (right now the path is only visible in the editor)? Here ...
1
vote
1answer
53 views

Non-Uniform Random Placement of Sprites

I'm creating a space game in Godot that has procedurally generated nebulae. A nebula is comprised of between 50 and 200 child particles, all with the same shader assigned to them which creates an ...