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.

1
vote
1answer
69 views

How can I reference C# objects in GDScript (and vice versa)?

I am using Godot Engine 3.0.6 Mono for Windows x64. I am prototyping the majority of my project in C# before I rewrite the game in C++ for release. I installed this plugin mostly to help with testing ...
0
votes
0answers
36 views

How can I change the parameters of the random events for each game entity?

I'm trying to write an easy-to-use random event system that has certain conditions and effects in Unity. It's a simulation game that contains multiple Person, City, Country, Faction elements. I have ...
0
votes
0answers
13 views

Using Azure with Unity

I currently use Unity 2018.3.9f1. I would like to hook up my Unity program to an Azure service, so that I can store/analyse information about user behaviour. As a primer, I tried to import the ...
0
votes
0answers
40 views

How does Unity store references to GameObjects in a scene

A Monobehaviour can have references to GameObjects in the same scene, but Prefabs, ScriptableObjects can't reference GameObjects in a scene. While Assets, Objects and serialization covers references ...
0
votes
1answer
56 views

How can I draw a rectangle with a color gradient?

I'm trying to implement below picture in my code but doesn't work. It only shows red color on all sides. I'm using line renderer and color gradient. Kindly check my code. Thanks in advanced ...
0
votes
0answers
31 views

How to update model transform of components when using physics?

I implemented a high level components system for my renderer and am curious about the right way to update the transforms components of models that have a physics rigidbody attached. I am using ...
0
votes
0answers
14 views

Scripting | Logic/Workflow problems

Im trying to make a Character controller, but I have some problems. I have a principal script where is the movement with velocity, and the jump, also there is a bool for when he can move or not. The ...
0
votes
1answer
26 views

Unity Proximity Warning System Trigger issues

I'm trying to set up a proximity warning system but I'm having some trouble. To simplify things as much as possible: I have two game objects in a scene (Object1 and Object2). Object1 has a large ...
1
vote
2answers
54 views

XNA: Classes with Texture2D to be treated as one

Summarised Problem: I have an Animation class that I want to be able to treat as a Texture2D field when need be. I do not ...
1
vote
0answers
35 views

Changing color for each element in linerenderer not working

I want to change color for each line (element) just like in color switch. But my code is not working. What I wanted is that the right line should turn blue then the down line should turn color red. ...
0
votes
1answer
28 views

Downloading image to apply as a Texture fails

In my app I need to download some images and apply them as Textures. If I use following code to get image from my local pc hard disk, it works. But it does not work if I use a url like (http://www....
0
votes
0answers
17 views

Button click event not triggering

I am using a button and have attached the appropriate onclick event, but whenever i click the button when playing the scene it clicks the button but it doesnt call the onclick event. Here is a ...
2
votes
2answers
44 views

Rotate on one axis, but visibly keep the other axes stable and editable

It's been a long two weeks. Quaternions are freaking complicated. I've managed to make a few baby steps towards finishing my project, but I've hit a brick wall and could use a few of your beautiful ...
0
votes
1answer
45 views

Check if raycast is hitting object

I am using the following which is attached on to an enemy, when I press the fire button it lowers the health of that enemy, my problem is HOW do I know if I am actually hitting the game object this ...
0
votes
2answers
63 views

How to avoid enemies overlapping each other when chasing player in Unity?

I am trying to get enemies to chase player but without them overlapping each other when they get closer to the player. So far what I have is that I check for the distance between current enemy and ...
0
votes
1answer
29 views

d3d11 renderqueue multi pass rendering design best practice

The goal: issue least calls to d3d11 ImmediateContext and render advanced effects like toon / outline / anything that requires rendering the same vertex buffers with at least two different vertex ...
0
votes
1answer
31 views

Unity Rendering (Bug): Objects rendered as multiple instances after repositioning

Context: I am currently making the menu for my game demo. It involoves "Raindrop"-Gameobjects (Sprites) being repositoned and recolored after a random amount of time. I do this by instantiating a ...
0
votes
2answers
33 views

Changing animator via scriping

I am using the following code, my intention is whenever the 2 objects meet the animator boolean changes and when leave change back to its original setting. But it doesnt seem to work. ...
0
votes
2answers
93 views

What method could I use to avoid using a lookup table for each item when loading a players inventory?

Let me explain a little about the pickup items and inventory to make this much clearer. Every in world item that can be picked up has a ScriptableObject assigned ...
0
votes
0answers
41 views

Staying in loop rather than keep executing

I am using the following code, which makes the game object look at me, walk towards me and then I change the boolean on the animation to perform an attack animation, the attack animation occurs on ...
0
votes
0answers
30 views

how to move array of GameObject at a time in particular direction in Unity?

I just started learning Unity and c#, my objective is to move array of GameObject at a time in particular direction in Unity
2
votes
1answer
66 views

Box2D physics are different on server and client

I'm using C# Box2D library for my server and client, they have similar world.step(), iterations and update function. At the same time they have different physics' results, difference is not fixed, it ...
0
votes
0answers
19 views

Multiplayer game- Client Shooting backwards

Making a multiplayer game. The Host shoots properly but the other players would only shoot backwards. Shooting script: ...
0
votes
0answers
26 views

When object is within a radius, stop moving

I am creating a zombie game using unity, I am using the following code to make the object (zombie) move towards me, but i am trying to make it stop moving whenever it gets too close. My intention is ...
0
votes
0answers
27 views

Unity build shows wrong date

I made a 3D game in Unity named Sniper Shot. I am facing a problem when I build the project: at the end it shows the wrong date of build. I have tried many scripts resolving this issue but I did not ...
0
votes
1answer
31 views

OpenGL frustum extraction

I'm trying to extract frustum planes from the camera. The algorithm is simple: create clip to world space matrix (inversed projection * inversed view) multiply clip point by clip to world matrix ...
1
vote
1answer
37 views

On escape key click make object visible

I am using the following code which works, But the first time i press escape nothing happens, if i press it again then the game object shows. Does anyone know why this is? ...
0
votes
1answer
38 views

When should you use a baseclass and a class as a datatype?

Im following a C# rpg game development tutorial atm and what confuses me is that I cant figure out when to use what. The author writes different classes where 1 class derives from another so the ...
0
votes
0answers
14 views

Defining the characters and mob classes architecture

I'm dealing with the creation of those little fellows that will give life to my videogame: characters. Right now I have a basic structure in mind that will represent these group of fellows but I want ...
0
votes
1answer
37 views

Struggle with resetting coroutine

A little bit of context; I'm still not experienced at this, I'm creating a 2D platformer and this is my enemies script (some part of it). This is supposed to be a minatour, which charges towards the ...
1
vote
2answers
100 views

I'm still not sure how to control each door individual?

What I want to do is something more or less very simple. The main bool flag lockDoors control all the doors and this is working fine now. But now I want to add a flag to each individual door so I can ...
0
votes
1answer
44 views

In Unity , How to clear instantiated object when I call the function?

Here is a function I call out am UI element: ...
1
vote
0answers
15 views

Keeping over-shoulder camera view consistent at different screen resolutions [duplicate]

I have a player GameObject. There is a character attached to it and a camera (both are children of the player GameObject). The over-shoulder camera is positioned nicely. The player should appear on ...
4
votes
1answer
157 views

How can I Implement spin in billiard game?

I'm not sure that you played billiard or snooker before.if you played you should know about spin. but anyway if you don't know about it you can see it in this video I want to Implement spin like this ...
2
votes
1answer
22 views

Can I run a script and generate warning when Unity project is saved?

Context: I'm working with Unity using Git and we have .gitignore setup so that we could create "_local" folder anywhere in Assets and it won't be commited. It makes for kind of a Debug/Backup folder, ...
1
vote
0answers
35 views

how to release unity webgl memory from asset bundle

I have stuck in a weird problem, in my Webgl project i am loading asset bundle frequently which is working fine but after unloading the asset bundle the memory is still not releasing. I am using ...
1
vote
0answers
27 views

How to add only 1 value in a list in the Update function when a GameObject is active for many frames

In my C# script, I get the active gameobjects during play mode. Those gameObjects that are active are: 1- First, I get the ones that the application has selected randomly 2- and then after the first ...
0
votes
0answers
10 views

Unity only projectiles shot by host visible to all players

I am currently making a fps multiplayer game, i have successfully made it so that multiple players can join and that they can see each other moving around. However there is a problem with the shooting....
2
votes
1answer
85 views

Which Pathfinding Algorithm is Best For My Case?

I'm creating a top-down space shooter game where there is no real "map" per say since there is no real terrain, but there are obstacles in the form of asteroids, other ships and a few circular ...
0
votes
1answer
43 views

Why doesn't this weaponpickup script work properly?

I'm making an FPS game. My guns are disabled at the start. When I use this script to pick up and hold one weapon at a time, requiring that you click J to drop it, it simply doesnt work! There are ...
0
votes
1answer
39 views

Make health bar follow the player not the camera

I wrote a script to create small bars of life & mana on top of the character. So far it's following him and everything ok, but the problem is that it has a delay, for example the player arrives ...
1
vote
1answer
162 views

How do I replace the enemy with a different graphic when it gets hit?

I am able to draw my space ship and a an enemy (called "bug_one" in the code below) and move my bullet. When the bullet hits the enemy, it draws a collision bmp. But currently my code draws both the ...
0
votes
1answer
26 views

Why is the Position Handle placed at certain distance away from vector3 unit in Unity?

I have a vector3 value that I am setting in inspector and I am drawing a ray using OnDrawGizoms to draw that vector line. However, the position handle I made using ...
0
votes
0answers
38 views

HLSL setting data on ONE Geometry instance - For chunk Terrain gen. SharpDX 4.2

I am just trying to send the size of an array from my c# script to my HLSL shader in order to initiliaze a vertex array inside the shader. It just ain't working. As I have read everywhere, we can't ...
1
vote
1answer
45 views

Bitmap drawn with Graphics.DrawImage flickers

I am working on a space invaders clone using bugs as aliens. Everything works ok but the bug bitmap flickers on the screen. ...
2
votes
1answer
118 views

Dr.Strange's door in Unity3D, how to put a projected void on a plane?

My question is about a visual trick I would like to perform in Unity3D. I want the player to walk outside a door and see no walls of the room behind them, just the door. They should still be able to ...
0
votes
3answers
136 views

Unity: Is type casting every frame too expensive?

I have a state machine that controls my enemy AI. Each AI has a target which may be a Player, an obstacle, a shell, or even a Vector2 position. I'm trying to abstract my "target" member, and my ...
0
votes
1answer
63 views

How to properly create a handle for setting moving platform's target position in Unity?

As the title suggests, I am trying to set up a handle for setting target position of a moving platform. I have an empty GameObject(targetPos) and this is what I want to use for setting target ...
6
votes
3answers
938 views

Lock enemy's y-axis when using Vector3.MoveTowards to follow the player

I am using the following code to make a zombie move towards me, but when playing the scene the zombie seems to be moving towards me, but also off the ground and not fixed on the y-axis ...
0
votes
1answer
102 views

Unity using 40% GPU for just a UI interface on ultra but 90 on low?

So I made some software using unity for my FRC team. All this application is, is just a User Interface with labels, input fields, buttons, etc... When I choose the quality to be on Ultra, I will get ...