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

How to extract data from a resource compiler script in c#

I need to know how to extract all data from a resource compiler script to a folder or the desktop. the .res files are compiled and added to an exe file. .res is the file extension. and if that is ...
0
votes
0answers
31 views

The doors lock system is working fine but how can I avoid changing the colors all the time in the Update?

I want it to change the doors lock state but also the colors of the doors Red = locked Green = unlocked either in editor mode or in runtime. But if the method that change the doors colors is not ...
1
vote
0answers
38 views

how to make a seemingly endless backdrop in Unity

Potential solution at the bottom. I have a rocket which flies straight up, as it gets higher you can see the edge of the terrain. I want the rocket to eventually leave the atmosphere and then the ...
0
votes
0answers
36 views

Questions about Jrpg NPC events (Unity C#)

So, I'm trying to wrap my head around something. I've got my basic quest system up and running for my rpg style game. Right now I'm taking a look at NPC events and triggers that as I see it have two ...
1
vote
1answer
42 views

Optimizing spawning 500 objects every 3 seconds

Using Object Pooling, assuming I'll like to spawn 500 cubes once every three seconds. How do I make it performance friendly? I need ideas, not the code itself.
0
votes
1answer
21 views

How to make a new powerup reset the WaitForSeconds from previous powerup?

I'm making a game where the player is pushing objects outside a plane. Every round there's an additional ball (GameManager.cs): ...
0
votes
1answer
23 views

How can I adjust the direction of my rigidobody.velocity without stuttering?

Stuttery movement has been plaguing me for the whole development of this project. Some info on the game: It's a 2D, top-down space game, and you control a spaceship that can accelerate or rotate. If ...
0
votes
0answers
21 views

Unity change scene with button

I already understand how to do this but the problem i'm having is: When i go from "MainMenu" to "Level01" and then back the buttons lose there reference. What can i do to fix this? ...
0
votes
1answer
18 views

How to stop counting point when player dies (Destroy)

In my game, I'd like to stop counting points when the player's y is -4. When the pink and red balls fall off the Plane the player gets points. But it seems a bit strange to be able to collect points ...
0
votes
0answers
46 views

Drawing a snake

I'm a junior programmer who wants to try the MonoGame DSK to create some basic games. I'm using C# language and VS17 and I'd like to know some things before starting. Let's begin by saying that this ...
0
votes
1answer
17 views

How to avoid game starting before start button is clicked?

I've made a game with a Title Screen (Canvas), and a Start Button attached to the Title Screen. Points, GameOver, Restart, and even the Start Button sort of works, but it's possible to play the game ...
0
votes
3answers
50 views

How to use GameManager to get GameOver() from another script?

I'm trying to make a gameover-text show when the player is leaving the plane-area. In GameManager.cs I've written: ...
0
votes
0answers
17 views

Unity Giving following error : NullReferenceException: Object reference not set to an instance of an object [duplicate]

im going to probably look really stupid and i will be no means admit this is my code however i cant seems to get it to work so i was wondering you you might be able to? I'm getting the following ...
0
votes
1answer
32 views

Why are Visual Studio and VSCode not giving me a dropdown list of methods and options etc?

I am using VSCode but I have also tried Visual Studio 2019 to write code for Unity, but when I'm writing the lines I don't get dropdown menus with for example the methods this class holds. Or objects. ...
1
vote
1answer
59 views

Why is my player not giving a knock back when it stays at the right side of the enemy?

So, I have this problem I am facing, for some reason my player does not get a knockback when it stays at the right side of the enemy but when it stays at the left side it gives a knockback. What's the ...
0
votes
0answers
27 views

How to start with Game Dev career with C# and Unity? [closed]

I'm a C# and Angular software developer. I'm trying to learn more about Unity, because I know C#. I'm been wondering how to start with game development and how to get a job in one enteprise?
0
votes
0answers
20 views

Switching between meshes vs Loading only specific mesh

I am currently developing an online multiplayer game on Unity. In the game, the character of each player will be assigned its mesh after the game receives parameters (their meshes' names) for each ...
0
votes
1answer
33 views

How can I use websockets in a Unity WebGL project?

There are plenty of good Websocket APIs for C#, but I run into trouble when targeting Unity WebGL due to this restriction described in the Unity documentation: No direct socket access Due to ...
0
votes
1answer
73 views

How can I simple use global or individual bool flag/s?

...
0
votes
0answers
51 views

Why the doors lockstate is all the false?

The goal is to change the doors lock state in the editor mode and also in run time. It's not working either in run time or editor mode. The problem is in the HoriDoorManager in the Update. The method ...
1
vote
1answer
62 views

How to receive a Knock Back when the player touched the enemy

I'm still new to C#, making my 2D game atm and my problem is how can I give my player a Knock Back when it touches the enemy. How to add it with this code? ...
1
vote
1answer
73 views

Unity conversion of Gameobjects to ECS

I have not worked with ECS before, so I was following the tutorial by Unity's Mike Geig on Youtube to convert gameObjects to ECS from Unite Copenhagen, and this code does nothing, and there are no ...
0
votes
0answers
21 views

Error: Object destroyed

When I try to run my game I have an error like this: MissingRefferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Here is my script: ...
0
votes
1answer
36 views

Unity Shader Blend like ugui Outline

Unity UGUI Outline it create fourfold vertexs, So I wirte shader to optimization ( vertex only create once ), And I want to Keep one pass . (one drawcall) There ...
0
votes
0answers
19 views

How to make progress bar in EditorWindow with Threading in Unity?

I need to make a progress bar in EditorWindow. To do this, I perform the function of calculations in threads: Thread thread = new Thread (_worker.Work); thread.Start (); The class itself emitting ...
-1
votes
1answer
42 views

problem changing texture from one to another

I have a problem that, when exceeding the maximum or minimum texture in the matrix, is giving this error, what can I do? IndexOutOfRangeException: Array index is out of range. ...
0
votes
0answers
17 views

How could I create those two meshes by creating procedural quads

I need to create 2 meshes procedurally and I don't know very well what order to give the vertices to show them correctly, is there any app/utility to help me establish those points? Images: Sapling: ...
0
votes
1answer
34 views

Unity get reference of GameObject under another GameObject

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

Velocity and drag in unity

So I have an object that is bouncing around the screen randomly, physics still works on it so it will speed up or slow down depending on what it hit and when. To try to normalize the speed I want to ...
0
votes
1answer
24 views

Unity List script field with +/- buttons in editor

I am using Unity 2018.4.11f1 LTS. I have a script with a public List<GameObject> field. In the property inspector, Unity provides a UI to this field where ...
0
votes
1answer
33 views

Stuttering when using movetowards in a coroutine

I have the following problem with a WebGL project I'm working on: I have an object which I want to zoom out and move to a specific position at the same time, for this, I've created a coroutine which ...
0
votes
2answers
84 views

Unassigned reference exception when proceeding from scene to scene

So, I have built a script in unity in c# called parralax. It basically parallaxes two backgrounds and looks like this:- ...
0
votes
1answer
57 views

Help with NPC following the player in a sidescroller

I'm a beginner with C# and am having a bit of trouble coding an NPC that follows the player in a 2D sidescroller. The player has two speeds, a walk and a sprint. I have a very basic companion follow ...
0
votes
1answer
80 views

Dealing damage over multiple frames without damaging the same enemy twice

I am using Physics.Overlap to find which enemies are in my damage range. But dealing damage in only one frame is not what I want. Some attacks should be active for ...
0
votes
0answers
21 views

Unity 3D - Materials are Stretching and Tiling doesn't Help

I am a programming student working with Unity 3D, version 2018.4.6f1 for this class. I wanted to add some materials to my wall, however, this results in a rather ugly result, because my walls are of ...
2
votes
1answer
36 views

Run script after game start, before scene load

I'm making some kind of dependencies solving script. To work this script, it must be run before all other MonoBehaviour scripts. So I made the script something like this: ...
0
votes
2answers
49 views

Center Gravity in Unity

a 2d planet in the center, where the players will be able to walk on it and also will be affected by center gravity. planet will be static and there won't be any other planets. so; Is there a way ...
1
vote
1answer
228 views

Inventory objects not persisting between scenes?

My Game Manager object has an Inventory script attached to it, which has "Don'tDestroyOnLoad(gameObject)" in its Awake function. During gameplay, items are pushed into a public List in this script. ...
-1
votes
2answers
22 views

Translate transform and RigidBody2d Addforce relative to world space

I'm developing a game with my friends from University. Currently, I'm in the process of creating a basic movement system for the main player with a box form as its mesh. I used transform.Translate to ...
0
votes
1answer
20 views

Why boxCollider bound extents change when changing the size of an gameObject but doesnt in the script?

So, I have two players when I first made them they were with the default size Y = 1. After I finished the scripts I wanted to change their size but when I did that, ...
0
votes
2answers
69 views

Using enums for detecting object collisions

As far as I know, I can detect what objects the player is colliding with is by the following code: ...
0
votes
1answer
38 views

How to make a follower script without diagonal movement

I’m working on a 2d game in unity. Right now I’m trying to make a follow ai. Where a character will follow the position of the player. I currently have it set it and working using the MoveTowards ...
0
votes
1answer
95 views

Unity3D - Camera Jitters When Displacing and Rotating Smoothly

DISCLAIMER: I am using Unity 5.6.5f1 for this code, I honestly don't know if there would be API updates on later versions, though I don't think so. I tried to make a simple Third Person Camera that ...
0
votes
1answer
41 views

Reading text from file changes the text?

I'm currently trying to load a simple text file and filter it by a certain string. In the text file I'm using a new line for each value and sometimes use a "--" to make things easier to read for me ...
0
votes
0answers
14 views

Object not clamping after applying force/impulse?

I am having issue with clamping the vertical position of my character after applying force. This causes a jittery effect in my character. There are other several ways I think of, but I dont know if ...
0
votes
1answer
60 views

Complicated How to create objects that fill a specific area?

How to create objects that fill a specific area? How to instantiate cubes within a random 2D form ... Trying not to leave the black lines. @ JaamiParvez Objetive:
2
votes
2answers
78 views

Programming logic to 2D point and click adventure/puzzle?

I am totally new to game development. I want to create a 2D Puzzle/Adventure point and click game similar to like 'Rooms' but scenes are connected. I have already done the inventory system but ...
0
votes
1answer
36 views

How should I load/change/activate scenes?

Scenes are confusing the hell out of me and I'm pretty sure they should be simple to understand. When the game loads, only the current scene has a buildIndex != -1. In order give it a 'real' build ...
-2
votes
2answers
38 views

Want to stop instantiating objects when timescale is set to zero

I have my enemies being instantiated from both left and right sides and I've used Time.timescale=0; for the pause menu script so whenever i pause my game everything stop other than the instantiating ...
1
vote
1answer
27 views

Load scenes inactive

When I call SceneManager.LoadScene() it will set the loaded scene as active. Can I load scenes at the game startup and just call ...