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
2answers
37 views

How to apply code of certain script to another?

I have a code in my "OnCollider" script to respawn whenever the player dies and has taken an object containing tag 'Respawn'. ...
0
votes
0answers
16 views

Unity 2d Player Glow like on off

I want my player to glow like in a loop of on and off for light it emitting and when he touches certain material with different light it should glow with that color
0
votes
0answers
62 views

LookAt mousePosition is not working properly Unity 2.5D

Trying to create a 2.5D game where I point my mouse to the direction of shooting, can't seem to figure out how to get the FirePoint pivot to look in the direction ...
5
votes
2answers
655 views

Snake movement in monogame

Noobie here... I've started learning monogame development and currently working on a simple snake game. I'm having trouble with the snake's movement, I figured I could make it tile-based movement but ...
0
votes
0answers
20 views

2d Character Crumbles after collision with platform

This is What Happens After Collision with Platform. when player jumps and collide Player gets Upside down or sometimes just on Back.any Help
1
vote
1answer
248 views

Hold and swipe can't work together

I Have a character in my game that must go when player hold finger at the screen, but when I swipe character first go, and then do swipe. (for example jumping - character first go, and only then jump)....
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
267 views

Toggle Button click doesn't count when the Mouse Up happens outside of the button area

I have a problem with my toggle buttons. When a user performs the Mouse Up of the toggle button outside the button area, the click is not counted. Mouse Down and Mouse Up on the button area works. ...
0
votes
0answers
5 views

Drawing several BeginArea inside a BeginScrollview (GUILayout) produces an unexpected behaviour

Well, I have a question with a GUILayout.BeginArea within a BeginScrollview. ...
0
votes
0answers
40 views

3d characters on 2d background game suggestions [on hold]

First off, I am wanting to get back into making games, I have made a few for personal use in gamemaker but never finished them as school always got in the way or they would get deleted when my ...
1
vote
0answers
17 views

Limit mouse movement within 2 points

I have a circle sprite that i only want to move between 2 empty game objects (points). Using Vector3.Lerp() I'm able to move the circle between those points ...
0
votes
1answer
119 views

Adding network support

I am trying to implement a simple game "Bulls and cows" in c#. It is a final project of my university course about design patterns. The target of the game is simple - try to guess the opponent number. ...
0
votes
1answer
128 views

Should I use dependency injection in Unity? [closed]

As learned about dependency injection on the internet, I found that it's something that can be done simply by the Singleton Pattern. But there are 2 completely different views on this issue: Some ...
0
votes
0answers
47 views

c# hex grid screen

I am able to draw a single hex to the screen. I want to draw a whole screen of hexes. Here is my code so far. ...
0
votes
2answers
73 views

How can I create a dice toss that results in a specific value?

I am trying to create a 3D dice for a game. Normal dice has been created by setting cube for dice with Rigidbody and apply force to throw a dice. Now the problem is, the user wants to give a value 1 -...
0
votes
1answer
23 views

Multi-level 3D grid based pathfinding in Unity

I'm trying to come up with a way to pathfind on multiple levels. See image: The orange walls would be considered a ladder, connecting you to the upper levels. At first I thought of looking at it as ...
0
votes
1answer
19 views

Unity - adding camera constraint to prevent the player from seeing beyond the scene

Like the title says, I'm after some kind of constraint for the camera to prevent the player from seeing beyond the scene and seeing the Skybox. I came across the code to add a ...
0
votes
1answer
86 views

Increment position every different value (C# UNITY)

How can I increment the position of the X and Y depending on its value Here's my code : ...
0
votes
1answer
37 views

Spawning player at a certain point after a new scene was loaded

I have a Game Manager with a DontDestroyOnLoad function on it, before loading a scene I'm passing the variables needed to reset players position to a certain position. This is what my code looks like; ...
0
votes
2answers
59 views

Detect when an Oculus headset is stationary/idle using transform.hasChanged

I want to know how can I change in unity the thershold of the method below: transform.haschanged At the moment it is so sensitive and it triggers with 0.00001 change in the camera. We have ...
0
votes
2answers
60 views

Foreach/list loop problem

i am having a problem with a foreach loop. When my AOE ability hits an enemy it creates a CircleCollider2D and puts all enemies on a list, which then the loop goes trough and adds damage to their ...
0
votes
1answer
22 views

Contracting Unity EditorWindow UI

How can I make scalable(contracting) EditorWindow UI(not in-game UI) like in inspector example?
0
votes
2answers
30 views

GameObject With Background Covers GameObject Without Background

so I have two sprites, a box and an X animation (I'm making Tic-Tac-Toe). So, in the code, when I click on the box, it instantiates the X animation at the right place. The X animation does not have a ...
0
votes
1answer
832 views

Unable to list target platforms. Please make sure the android sdk path is correct. (Error)

When i am trying to build an apk from unity. Than its show me some error something like this :- ...
1
vote
1answer
14 views

Unity - IsTouchingLayers problem

I'm experimenting with 2d physics, and the problem is this: The IsTouchingLayers function reveals that the object is touching a layer, but only if I use the...
3
votes
2answers
1k views

How do I resolve the error “Trying to send command for object without authority.”?

I don't know what I did wrong I tried couple different ways from not using commands to using SpawnWithClientAuthority. But It either gives build and compile errors ...
-1
votes
0answers
19 views

Creating objects in one for loop and destroying them in another [on hold]

I need to dynamically create some objects in a for loop. After they've been created, I need to destroy some of these obects in a second ...
3
votes
1answer
322 views

Efficient 2D grid overlay on tiles without each cell being its own GameObject

So for my game I need the ability to add a grid overlay over my tilemap. Now I don't think that making the grid with each cell being its own GameObject with some SpriteRenderer would be hard to do but ...
3
votes
1answer
222 views

Trapping Asserts in Visual Studio

I'm writing a 2D game with some fairly complex off-screen logic, with plenty of room for bugs. My usual habit is to write code with a lot of Asserts in it. When an Assert gets hit I drop into the ...
0
votes
2answers
757 views

How to draw the elements that are in a Texture2D list in XNA

I have a Texture2D list called blockTexture that has 2 elements in it. I use the following line to draw the first element. ...
0
votes
2answers
23 views

How to detect whether a transform has rotated left or right

I have a game object in my scene, and I want to know how can I calculate whether this game object rotating to the right or to the left. For example : ...
0
votes
0answers
14 views

object reference not set to an instance of an object [duplicate]

hello i have a error "object reference not set to an instance of an object" when my ball collide with the spikes.its supose to remove one heart but it doesnt. health code: ...
0
votes
1answer
34 views

Quaternion.LookRotation with Joystick

I am having an issue i cannot seem to figure out within my code. What this code does at the moment is that it rotates the 3D Model around the z axis but i need it to rotate around the y axis. Any help ...
1
vote
2answers
62 views

Detect Collisions While Dragging 3D Game Object

Hello i am making a game in which i have to drag a sphere on x axis and z axis on a plane with my mouse and i have created walls from cubes so that my sphere not go anywhere else in the game but while ...
0
votes
1answer
58 views

How can i rotate gameobjects back from mirror?

For some reason when i create the gameobjects they are places like mirror. And i'm not sure how to rotate them back. ...
0
votes
1answer
23 views

Getting the same message while using Facepunch.Steamworks

I use Facepunch.Steamworks for P2P game made in Unity, so I send packets through it(UnreliableNoDelay sendtype), but I've got a problem, since I send message like this: Move:0 and get this: Move:00,...
0
votes
1answer
101 views

Raycast Issues in Unity

I am working on a 2D platformer for mobile. I am trying to set up the shooting for my character. The character's shooting usues a raycast to kill the enemies. I am also trying to setup ads to work as ...
0
votes
1answer
18 views

Unity - rotating character for 2.5D platformer

I'm currently making a prototype for a college project in Unity. The game is a 2.5D platformer, though I've incorporated a script for the camera from a 2D platformer so the camera moves ahead of the ...
0
votes
1answer
604 views

Zoom at a specific point using Orthographic camera

Currently I can perform Zoom which seems to be working fine but essentially what I'm really trying to do is zoom on a position offset from center as currently when I zoom then zoom is performed at the ...
0
votes
0answers
10 views

Joystick Orientation Wrong After Camera Rotation

I am using a virtual joystick to move & rotate the player and a touch swipe system for the camera rotation, The problem is that when I rotate the camera (Let's say I rotated the camera to 45 ...
0
votes
1answer
67 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
35 views

Character rotation according to camera causes rapid flipping when game starts

When I load my scene, my character rotates +90 and -90 on the X axis very fast about 4 or 5 times, and then he stops at -90 on X axis (lays back down). When I move the character, the rotations are ...
0
votes
0answers
8 views

Stop audio in all scenes using a slider in the main menu

I am using different sounds in different scenes, but problem is that I can't stop all sounds using slider in the menu. It stops only the menu sounds, or sounds for the current scene. When my game ...
1
vote
1answer
385 views

How to compute a heightmap and use as 3d voxel floating point

When you want to compute a heightmap and use for 3d voxel binary, it's easy. solid are maybe 1, and air are 0, easy. But in my case I would like to have a smooth terrain, so the solution is the ...
0
votes
0answers
12 views

Instantiating tiles

I'm writing a game that instantiates a large gameBoard. For some reason the below code won't instantiate tiles across the Y-axis. All 10000 tiles are instantiated in a straight line across the X, and ...
0
votes
0answers
21 views

Which “using” directive am I missing? [closed]

Habitually, I write at the beginning of my C# scripts: using System.Collections; using System.Collections.Generic; using UnityEngine; When I write: ...
0
votes
0answers
10 views

Move & Jump Character in Unity (Book “Unity in action” 1st edition)

I, according to the book Unity in Action, studied Chapter 7, I don’t know whether I’m doing something wrong or a bug in the book. In general, the Character Controller clings to objects and it turns ...