Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c#]

C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.

0
votes
0answers
6 views

Ensuring a Recursive method completes in one update tick?

OK so I have a method that calls itself as this was the only way I could think to get the behaviour I needed. Its a tetris clone i am making and this method is for checking for full lines across X ...
0
votes
0answers
13 views

Formula to keep certain amount of space at top and bottom of object

I have created an inventory, it's a suitcase that hosts items (like ammo, weapons etc.). No matter which screen resolution the user has, there always needs to be a certain amount of space at top and ...
0
votes
0answers
5 views

How do I debug Azure Spatial Anchors with Unity on an Android device?

I've been building an AR app that's already been a pain to debug, because instant preview refuses to work over wifi and usb debugging causes the phone camera to not display on the phone itself. Now I'...
0
votes
0answers
32 views

Can I detect collision on specific collider?

I'm a beginner with Unity and I'm developing my very first 2D game. My game character needs to have an automatic right/left movement but I'm struggling with the colliders on the walls (I made a ...
0
votes
1answer
12 views

Input.GetAxis Vertical - Unity - can i force it to zero upon certain circumstances/event?

I am trying to make my own tetris clone. I have actually got very far into it without running into major problems, but I am now stuck and can't find the answer after searching. Basically I have used ...
0
votes
1answer
16 views

GameObject keeps snapping to camera size on play

I'm in the process of making my GameObject move when I drag it across the screen using touch. But my current issue is when I press play to test the game, game object snaps to the size of my camera on ...
0
votes
0answers
27 views

Input.GetAxisRaw not returning zero after releasing the key

In my WebGL Project here is the way for camera navigation (Movement/Rotation) on Update event: ...
-1
votes
0answers
21 views

Unity - Parameter does not exist

I've tried asking on the Unity forum, but as always, I little to no response, and this is really frustrating me. I've never had this issue before when setting up animations or Animation Controllers. ...
-1
votes
1answer
45 views

Return the success or failure of an event occurring with a given percentage C#

I'm working on a skill based system that does away with the concept of RNG despite player skill. Basically, my concept is this: A player's chance to make something is based on ...
0
votes
1answer
31 views

Textmesh Pro conflict in Unity2019.1.5f1

I'm having an issue with Textmesh Pro in my project. I originally got it from the Asset store a few months ago. More recently, I deleted it and downloaded it from the Package Manager. However, now in ...
0
votes
1answer
17 views

How to set up Azure Spatial Anchors with Unity Android project?

I'm building an AR app in which I wish to use Microsoft's Azure and it's web service Spatial Anchors. I cannot seem to get the sample demo, which I downloaded from https://github.com/Azure/azure-...
1
vote
1answer
26 views

Using grids from a different script

I suspect there is a very simple answer to this one but I have been scratching my head trying to figure it out for a while. I have this piece of code that works fine. It effectively adds the location ...
0
votes
1answer
54 views

Alternate Answer for collision problem?

I am building a top-down game in unity which works well. In this game, I have a 3D object (red cube) which a player has to control and there are other cubes like white, yellow and black cubes which ...
0
votes
1answer
26 views

Unity - SpriteRenderer. Trying to make sprite from code using Texture2d.whitetexture

I have been trying to write a method that fills a rectangle with a color. I've tried it as a new 2D and 3D project just in case, but this gives the same results. Basically, i want the script to make ...
0
votes
0answers
14 views

Unity Timeline controls

Can anyone show me how I could play the timeline backwards through code? Like, after Cinemachine has done cut scenes, and I'll want to reverse the whole cut scene back to how it started, how exactly ...
-1
votes
1answer
28 views
1
vote
1answer
70 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
12 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
71 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
19 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
20 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
17 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
2answers
187 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
47 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 ...
0
votes
1answer
31 views
1
vote
1answer
19 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
51 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
52 views
0
votes
2answers
31 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
26 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
28 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
34 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
49 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
17 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
49 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
43 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
44 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
169 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
12 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
28 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
80 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
77 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
42 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
61 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
23 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
19 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
21 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
59 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() ...