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
0answers
36 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
177 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
40 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
140 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
939 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
103 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 ...
-2
votes
1answer
34 views

Moving a 2D object up & down y axis within certain limits

This was originally written to move a 2D object along the negative x axis. Now I also want to move the same 2D object along the y axis (up and down within certain limit and at different speed than ...
0
votes
0answers
31 views

Hi,Dynamically modifying meshes in Unity3D

I'm working in Unity3D and I want to remove sections from a mesh at runtime similar to the idea of bombs removing sections of walls. In 3D modelling software this is a pretty standard Boolean ...
1
vote
1answer
66 views

Why I keep getting null exception?

If it's needed I will add the completed script code of the Prefab Replace EditorWindow type. I packed exported the project to a file and uploaded the packed file it's 31MB only. My unity pack In ...
1
vote
1answer
39 views

Defining a projectiles speed and angle before Instantiating

I have a 360 degrees shooter object and a projectile to shoot. My projectile has a Rigidbody2D with zero gravity scale. I want it to bounce off of colliders when it gets hit, but when I instantiate it ...
3
votes
0answers
110 views

Unity3d: calling a web service in unity editor works, but not in standalone. Why?

I have this line of code: SDE3D _webService = new SDE3D(); int result = _webService.UserLogin(txtLoginUsername.text, hashString); My ...
1
vote
1answer
25 views

How to store Unity Component after destroying a GameObject

I have a collectible item, which I can put into the inventory. Its GameObject has a InventoryItem script attached in which I want to set all parameters needed for correct display in the inventory. ...
1
vote
1answer
26 views

How can I add array of components to a new gameobject?

I use Getcomponents to get all components from existing gameobject: Component[] components = go.GetComponents(typeof(MonoBehaviour)); And I want to add them now ...
0
votes
0answers
15 views

Resize game object using single drag handle using Unity

Really need your help. I'm trying to create a custom controller for my app to allow users to resize and rotate game objects using a single drag object. I was able to create the code to create the ...
0
votes
1answer
17 views

Calculate required position to keep object centered when camera is rotated

I always want to keep an object in the center of view of a camera. When the camera's rotation X value is -45, the object should still be centered. Therefore I need to calculate the new position of ...
1
vote
1answer
61 views

Handling damage taken by enemy

I'm learning the basics of combat system by doing it myself, but there is a logical problem I can't figure out. It's on Unity2D, using C#. ...
0
votes
1answer
65 views

How to rotate CharacterController on slope

I'm trying to rotate my characterController player on a slope on the 'x' and 'z' axises, however things aren't going so well. The player does rotate, but if I move and look in another direction, the ...
0
votes
0answers
52 views

Return value from function in unity webgl and javascript communcation

I am using Unity webgl for my project and want to communicate from browser JavaScript to C#. One way is to call C# function from JavaScript using SendMessage. I am easily making call using this code ...
0
votes
1answer
26 views

How can i set OnClick equal to UnityEvent

The Problem I'm making a dialogue system for a small 2d rpg. I Have a Dialogue class with two lists for pages and responses. The response class has a UnityEvent so i can use the ui in the inspector ...
0
votes
0answers
20 views

I cant Instantiate a particle system for the duration of a subroutine

I have a sub routine that lowers the timescale to 0.3 for 2 seconds. while in those two seconds i would like to spawn a trail of particles that follow the player. I can get the particles working if I ...
0
votes
1answer
39 views

OpenTK OpenGL wierd camera look

I am trying to implement a simple camera mouse look. ...
0
votes
1answer
134 views

Rotating game object without using localEulerAngles

I'm building a player controller. While aiming, the player can rotate the chest bone. This looks as if the character aims in different directions. The chest bone should only be allowed to rotate ...
0
votes
1answer
69 views

What aspect of performance should I be optimizing my code towards? (asynchronous chunk modification)

Preface I realized that the root of my question is a little simpler than all of the details below make it out to be. All other things being equal, what is the most important system aspect to optimize ...
1
vote
0answers
106 views

How can I approach writing a GUI framework for my game? [closed]

The problem I want to write a simple GUI framework designed for a game, in order to learn the inner workings and nitty-gritty of how GUI 'engines' such as Unity3D's GUI work. I can't find any ...
1
vote
1answer
58 views

Rigidbody & Ray alternative or optimization

I am creating an AI that moves around to certain points, but should interact with ais or objects seen. The ai should find other ai to comunicate or look for objects on the ground. It works with all ...
0
votes
1answer
87 views

Unity3D: Replicating SM64 turning movement into Unity

Brief Summary: I want to recreate Super Mario 64 turning movement into unity without the clunky movement I currently have. And I would also love how to implement the camera rotation system mentioned ...
0
votes
0answers
21 views

WebSocketSharp issues when used for online turn-based game in Unity

I'm using Websocket-Sharp in Unity for a turn-based game to communicate with a server. As I said here, This library has a major problem with detecting connection lost when turning on/off VPN in ...
0
votes
1answer
75 views

how to get if a rotation/position has been completed?

I've done an if / else with the final position / rotation plus they never complete, how can I check this? stays like this https://i.imgur.com/3cQ9AEk.gif ...
0
votes
1answer
93 views

Read text file line by line [duplicate]

How do I read a text file in Unity line by line? I want to get a line, read in the object listed, and instantiate it.
0
votes
1answer
32 views

Difference between 2 quaternions

I need to patch an animation during LateUpdate. I'm rotating the "chest" bone according to the mouse delta. This is to mimic aiming a pistol. During this aiming, the "neck" bone should stay ...
0
votes
1answer
53 views

Instantiate prefabs at particular vectors using text file (Unity3D game)

I need to read a text file containing two pieces of information on each line, and use that information to instantiate a prefab at the correct location in a Unity3D game (c# script). The locations are ...
0
votes
1answer
34 views

OpenGL Texture Zig-Zag Artifacts Over Time

I'm working on a deferred shading renderer in OpenGL, where I write all geometry output to Colour, Normal and Depth textures and then apply lighting effects later. Everything seems fine except once ...
1
vote
3answers
86 views

how do I tile this generated terrain infinitely around the player?

i made a script that instantiates cubes with for loops and perlin noise. is there any way i can tile this infinitely around the player? here is the script for the generation of one tile ...
0
votes
1answer
41 views

In 2D, how can I improve character rotation using raycasts when dealing with sharp/convex edges?

Edit: After making some edits to my polygon collider (based on @Alex F's suggestion), I can indeed confirm that sharp, convex corners are causing the buggy ...
0
votes
1answer
58 views

How is the default value of ContactFilter2D.isFiltering true?

I have a static ContactFilter2D like so: ...
0
votes
1answer
24 views

Mathf.Hermite not available in Mathf

I see here that Hermite should be function in the class Mathf. However, when I try to use it, the compiler tells me that Mathf doesn't contain a definition for Hermite. This is an example: ...
0
votes
0answers
30 views

Unity: Get excel type data from an html website

So is there a way that I can use an html page as a database? My end goal is to put everything into an excel sheet that the people I am making the application for want. I need to upload data from the ...
0
votes
1answer
56 views

Unity & CSharp - Placing Instantiated Object in the Direction of Player

So, I am making a Minecraft ripoff. I have a raycast that hits a block. It then places a block inside of that block. I am trying to make it place next to the block in the direction the user is facing. ...
1
vote
0answers
13 views

Set specific animator-state as more important

I have a animator with 3 states: KnifeWalk KnifeIdle KnifeAttack The KnifeAttack state should be run, whenever the bool "Attack" is set to true. This always ...
1
vote
2answers
55 views

Trying to set up a planting and harvesting system, but it only works in one trigger area?

What I want to happen is when the player presses alt, some time passes and an object is instantiated there. I also want it so that the player can't instantiate another object there until they've ...