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
1answer
217 views

Preventing overlap in OnCollisionEnter2D

So I have successfully built a script that can determine the physics for a ball reflecting linearly off of walls, similar to pong, while the ball is using a kinematic rigidbody. The issue is when the ...
0
votes
1answer
36 views

Having issues with 3rd-person Camera Raycasting / Local<->World Space / Clipping

I would like my camera to inherit the player in the hierarchy, and get closer when there is a wall or floor between the player and the camera. Right now I am trying to raycast from the player to the ...
0
votes
0answers
16 views

Best practice for getting references to gameobjects unity

When structuring the script to control a gameobject with several generations of children underneath, I gather from one of Jason Weimann's videos that it's a bad idea to use the string based methods to ...
0
votes
1answer
56 views

Centring content within a scroll area

I've got a Scrollbar with a dynamically generated number of entries, and I'm trying to figure out how to get it to act so that there's a lead-in of the first 3 items (example number based on the size ...
0
votes
1answer
451 views

Smoothen line on linerender

I've created a square using linerenderer but my problem now is that the line is not smooth. see below picture. I've tried enabling anti-aliasing and setting lr.numCapVertices to no avail. ...
6
votes
1answer
304 views

Lidgren not starting server properly

I have a server set up for my game with Lidgren, and it works well when I have it set up on one machine, but if I try to run the server on another machine, I am unable to connect from other machines. ...
4
votes
2answers
67 views

How to not cover up the Android/iOS top status bar (eg. with time, network/wifi icons) in mobile Unity app?

I am making an Android/iOS mobile app in Unity. Currently, when I build it and install it (for example from APK to Android) it loads completely full screen covering up the top phone status bar which ...
0
votes
2answers
2k views

Monogame Drawing Text

I'm really new at XNA. I've been following some tutorials at gameprogrammingadventures.org but when it comes to conversations I don't really like how the author does it so I've been trying to ...
3
votes
1answer
321 views

C# XNA colliders, physics, inclined plane/terrain/colliders

Currently I'm working on a project to learn game programming. But I'm not sure if I have the right approach on several things, and that's what I'm here for. What I'm trying to create is a small world ...
2
votes
1answer
35 views

Spritebatch drawing the other way

I am drawing a rectangle using a emptytexture (1x1) and I use the following: ...
1
vote
0answers
25 views

How to program different types of monsters

I'm working with a group of programmers and I'm trying to program different types of monsters in Unity. I want to make it so that all the monsters have values like attack power, attack speed, moving ...
0
votes
1answer
83 views

Coroutine only partially executing

I have a Coroutine that I use to pull and spawn an enemy in my game. This coroutine works perfectly fine, with the exception of the very first call. I am fairly certain this is because I am probably ...
0
votes
1answer
433 views

Animate Loading Screen During CPU-Heavy Scene Load

I have a scene with lots of lightweight objects and one that takes anywhere between 10 and 45 seconds to load. At a high level, the Awake method does... Query database For each result do some (fairly ...
0
votes
0answers
10 views

How to select one game object and move it?

For example, I have two game objects, cube1 and cube2, in a scene. I want to be able to click on one and move it. I know how to use ray to highlight it, like below: ...
0
votes
1answer
90 views

Why isn't my BoxCollider2D doing anything?

I'm trying to make a speech bubble appear when you approach the tutorial board. The bubble is there and it has its animation states "Appear" and "Disappear" Appear is called OnTriggerEnter2D ...
0
votes
1answer
414 views

how to create a curve movement of slider in unity

I am trying to create a curved (not circular) movement of slider. Here is my demo images for reference: I have watched some tutorial but those are for circle images. I want to make this movement ...
1
vote
1answer
577 views

How to create laser redirection?

Think portal 2, where a laser can go through a cube, and depending on the rotation of that cube, it will redirect it. Examples: Here is my barely functioning code. It works for one cube, I'm able to ...
0
votes
1answer
82 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 ...
0
votes
1answer
1k views

Check if raycast is hitting object [closed]

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 ...
-2
votes
2answers
143 views

How to store a Transform[,] grid in an ArrayList?

I am new to Unity game dev and trying to expand my knowledge of data structs. I'm building a match-3 game, and I currently have a multi-dimensional ArrayList holding transform coordinates on a grid of ...
0
votes
1answer
672 views

How can I get the speed of finger drag using unity TouchPhase.Moved?

I'm making a mobile game where you control a 3d ball by touch. So far I can get it to roll based on finger down and drag (via TouchPhase.Moved) but I want to be able to detect a fast flick or finger ...
0
votes
2answers
1k views

When scene loaded up, Position player at a start point. (Unity2D)

If pointName and player.startPoint are true, shown by the inspector, why doesn't the player's position go to the start point with a pointName of "ToNeighborhood". Note: The code runs if pointName == ...
0
votes
1answer
58 views

I'm still not sure why the reverse state is not working?

The goal is to be able to change direction(reverse or forward) at runtime in real time without waiting the transform to reach the next waypoint first but at real time to change the direction/s. ...
2
votes
2answers
545 views

UI Button OnClick not playing AudioClip on gameObject

Basically, I am loading an Audio Clip onto a game object's Audio Source in the Awake function when the game starts. When I click on the game object a UI comes up that basically has a Play button ...
-1
votes
0answers
24 views

HelloThis is error I getArgumentException:Objectoftype'UnityEngine.Objectcannot be convertedto typ'UnityEngine.Collider'.System.RuntimeType.CheckValue [closed]

using System.Collections; using System.Collections.Generic; using UnityEngine; public class NeeeeeeeeeewGather : MonoBehaviour { ...
1
vote
1answer
164 views

Unity Raycast works only once-Ignores NavMeshAgents

I'm new to unity and just trying to build a game. I've been trying to use Raycast to detect if an enemy is next to the player and I can't seem to get the Physics.Raycast working properly. Everything ...
1
vote
1answer
56 views

How to assign a specific Item index to my inventory when picking up items?

I want to make an inventory system for my game, and I found some issues when collecting an item. What I want is to match the index in the Inventory_UI system ...
0
votes
2answers
133 views

Detect Mouse Enter on An oval shape image in unity

I have an image that is attached to a panel and I want to detect On Pointer Enter and exit. The event is working fine but currently, it is working on the full image while I want to detect this event ...
1
vote
1answer
152 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
0answers
28 views

Avoid clipping objects when looking at them close-up in the Scene view

I am making a game in Unity3D, but whenever I get about 5 meters close to an object, the camera acts like I am right by it and does not render part of the screen. Here is a screenshot: This is really ...
1
vote
1answer
962 views

Avoiding GC Allocation in Unity UNet API

I'm trying to profile the game using Unity Profiler, I can see in the Hierarchy tab that there's an 18.3 KB correlated to ...
0
votes
2answers
277 views

Creating dependent values in the Unity inspector

I want to create a few values which will be dependent on each other. Specifically, I want total sum of few values always be 100 In unity inspector no matter how I tweak them. E.G.: ...
-2
votes
1answer
24 views

Why I'm getting message in the editor console window , Look rotation viewing vector is zero?

Look rotation viewing vector is zero UnityEngine.Quaternion:LookRotation (UnityEngine.Vector3) Waypoints:Update () Why I'm getting this message and what should I do with it ? It's not a warning and ...
0
votes
0answers
39 views

How can I draw gizmos only at runtime?

...
-1
votes
1answer
36 views

How do I create a method that adds a new sprite to the game?

I want to have a script in my game that adds a card. I am using a Card class for all my cards, so I don't have to make a prefab for each card. Instead I can do ...
0
votes
0answers
32 views

How to snap an object to an axis in 3D?

I have a script that lets player move a Rigidbody in my game with a mouse, and I want some objects to snap to other objects' axis (let's say guide) when they are near. So when an object is close to ...
0
votes
1answer
214 views

How to get tile rotation from TiledSharp and convert it to XNA/MonoGame

I am currently working on a game using XNA and Tiled. I use Tiled to create my maps and load them using TiledSharp. Some of my maps have tiles that are rotated by using one or more of the left rotate, ...
3
votes
6answers
11k views

Why is ScreenToWorldPoint always giving same coordinates with mouse position?

Whenever I use ScreenToWorldPoint(Input.mousePosition) and display the output in console this always gives me the same coordinates. MyCode: ...
0
votes
0answers
39 views

Increase or decrease values based on another value with diminishing returns

I'm making a village building type of game in Unity (using C#). Of course we have the classic villager who can chop trees. In my game I want the player to care about their villagers by making them ...
2
votes
1answer
905 views

Why is there only one variable displayed in the Inspector?

Using the following code, only one variable is shown in the inspector: [SerializeField] private GameObject _obj; This makes sense, since there is only one field. ...
0
votes
1answer
682 views

Implementation a Prefix tree or Trie in Unity C#

I am trying to make a word game in unity. The game shall be an online game with 4-6 players. The gameplay is somewhat like this: Suppose 4 players are playing the game- p1, p2, p3, and p4. All ...
3
votes
3answers
295 views

Animation clip not working

I am working on playing different animation of key press.Below are the animation element attached to my player Initially run animation is played.I have written code to play "Jump" animation on ...
-1
votes
1answer
27 views

How to rotate my enemy so it scans the area?

Hi I am new to unity so I am not super familiar with methods. I am trying to make my enemy rotate left then right double the amount that it rotated and back to the middle like this: +10 degree, -20 ...
-1
votes
1answer
29 views

Why does a public variable define a private one? [closed]

What is the point of such work with variables? public GameObject Obj => _obj; [SerializeField] private GameObject _obj; A private variable loses its privacy ...
0
votes
0answers
25 views

How to save a class full custom property types and their data to disk

Background: My app is a sandbox with a large number of parameters that I want to be able to easily add / selectively expose to the user, edit during runtime through the game UI or from the Unity ...
2
votes
1answer
40 views

How to generate a correct RGB + Luminance histogram?

I am trying to create a debug tool that would help me visualize an image RGB and luminance histogram. I have created a compute shader where I gather the histogram data ...
0
votes
1answer
645 views

How can I render attack ranges as in this screenshot?

Divinity: Original Sin 2 has an amazing range-of-attack display. When I select a character's abilities, the range of the ability will appear (as shown in the screenshot below). I'd like to know how ...
0
votes
2answers
36 views

How to make windows that pick up what appears in the other

Basically there are 2 windows that you can drag and drop around the screen. Whatever appears in one window will also appear in the other. The two windows cannot go one over the other. This is a demo ...

1
2 3 4 5
154