Stack Exchange Network

Stack Exchange network consists of 174 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
0answers
28 views

Object coming from far away effect in 2D

I have a path made using segments of sine wave interpolation put together that is drawn flat on the screen. And I would like to give the path the effect of coming towards the player. I tried to draw ...
0
votes
1answer
13 views

How can the ball moving like billiard after collision with wall?

I tried ball.velocity = Vector3.forward * speed and also *=-1 when the collision is occurred(It only works for straight way. But I want the ball movement be liked in photo. How can i do it? Thank you ...
0
votes
0answers
15 views

Fail to Start android service in android studio Unity

I have written a service file in android studio like: Manifest file: ...
0
votes
0answers
14 views

SDL2-CS and Gtk Sharp like SDL2-CS and WinForms in C#

who knows SDL2-CS embeds in Gtk Sharp 2/3? Similar example by Ethan Lee with Winforms But I really want know how do I fix with SDL2-CS in Gtk Sharp because I am working under Ubuntu 18.04 SDLWidget....
1
vote
2answers
34 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
42 views

Why does the drag fail when I move too fast?

I got this code that drags a 2d sphere when i touch the screen: ...
0
votes
1answer
22 views

XNA 4.0 How to combine triangles vertices 3D

Preview for the problem: I'm making a similar game to Minecraft (a game that it's world is made by cubes), but the fps of the game is getting low only by rendering a little amount of cubes in the ...
1
vote
1answer
27 views

Camera to the right from the character

I'm trying to create a camera like in Fortnite or Gears of War. It's focus must be to the right side from the character: But when I rotate the camera, the character slightly shivers. Lerping and ...
0
votes
0answers
51 views

WHY !! CountDown not Working inside the IF Condition? [duplicate]

i need a way to make the countdown decreasing inside the if statement i am stacking in this problem for more than 3 days .. Don't suggest to me Coroutine cause it will not working in my case cause i ...
0
votes
0answers
17 views

XNA - How to scale sizes and speeds for a minimap?

I'm recreating the arcade game StarGate, and I need to create a minimap. But I'm having problems scaling the minimap textures to fit in the radar box, and ontop of that, making sure the speed of the ...
0
votes
1answer
21 views

SerializedProperty to UnityEvent in a Custom Editor

I am making a Custom Editor for a type that includes a UnityEvent property. I'm currently facing an issue in converting a SerializedProperty to get that UnityEvent. Here is how I declare the event ...
0
votes
0answers
19 views

Android studio background GPS service call and Unity

If I have a service file written like this in android studio: Manifest file: ...
0
votes
0answers
39 views

In Unity, my joystick button only works a few times, why?

My part of the input code looks like this: ...
0
votes
0answers
6 views

Unit Getcomponent error for bookmarks functionality in my game im using playerprefs

this is my bookmark functionality. ...
0
votes
1answer
19 views

Touching screen not working for move object or print message

It's simple, i want to move an object when i touch the screen, but code's not working, i tried to just put a console printing on it, but nothing happens: ...
0
votes
0answers
34 views

Why does my character's collider only jumps with the animation while walking?

My character's collider only jumps with the animation while walking. And when he runs he gets stuck in the air and can walk in the air. Here's my script for jumping. At this point I have tried ...
0
votes
1answer
39 views
0
votes
0answers
11 views

Check if client is owner of object

I am creating simple multiplayer game. I am familiar and know everything about sending messages client > server and server < client but now i came upon one question. How to check if object (in my ...
0
votes
2answers
76 views

the countdown timer inside while loop not working [duplicate]

i am instantiating prefab cars ... the clones had a random countdown timer with each one off them and its working very well but the its not decreasing its not counting down the timer is inside the ...
0
votes
1answer
53 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
17 views

Error modify bools from script1 iin script2 then get bools value frrom script2! [duplicate]

I have a GameObject called "emptyobject" with a FullOrFree component attached, containing several public boolean variables: ...
0
votes
1answer
118 views

How to start a game with “3-2-1 go”?

I want my game to start after a "3-2-1 go" countdown. My Player Script : ...
0
votes
1answer
50 views

Server-side real time position calculation based on destination position - C#

What I want to achieve is to calculate the real object position based on its speed and a destination position. In my server, I have a MapInstance that have a list ...
1
vote
1answer
17 views

Inflating a balloon while the user touches & holds the screen

I'm trying to create a simple balloon which will enlarge as the user touches and holds the screen. So I wrote something like this: ...
0
votes
1answer
18 views

Access a clone of an instantiated object - not all the clones?

I am trying to access the object I instantiate - basically a prefab car instantiates cars (one after one) ..the problem that when try to move one .. they all move together ... what's the best way to ...
1
vote
1answer
43 views

In Unity C#, how can I change weapon a few frames later?

I have this Input code to change weapon: ...
0
votes
1answer
24 views

Sprite won't change with direction

I am making a top down Pacman game. I have two sprites: one for facing up and one for facing left. When I press W, the sprite showing is still the one for when Pacman is moving left, but I want to ...
0
votes
1answer
38 views

If statements seem to act as though the condition is always true

I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if the if statements below are working and none of them worked! I don't ...
0
votes
1answer
16 views

XNA 4.0 How to change GraphicsDevice Default DepthStencilState Value

I want to change one of the deafult values of my GraphicsDevice to that: GraphicsDevice.DepthStencilState.DepthBufferEnable = true; But I know only to change it ...
0
votes
1answer
29 views

How can I use the colours of a swatch in a script?

In Unity's editor I have set a swatch with some colours that are used throughout our game: This swatch is saved in a file in the project's Assets folder: ...
0
votes
1answer
27 views

Unity - Calculating a rotation based on game time

I have a simple script to make an object spin: Spin Speed is the speed to rotate the object on each axis (preferably in degrees per second). Local is whether the rotation should be done based on ...
0
votes
1answer
19 views

Unity - Instantiate GameObject from client on Network

I am building a game where a weapon shoots prefab bullets. I am trying to make this a multiplayer game, so the bullets need to be spawned into the Network. What ...
0
votes
0answers
19 views

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

How to solve this nullreferenceexpttion ...
0
votes
1answer
43 views

checking if an array rank is not equal to an int C#

I'm creating an inventory system for a dungeon crawler, I've got world gen, and player controls down, and this is the only snag.` ...
0
votes
2answers
50 views

Why does using .Lookat() cause the enemy to look left instead of at player, and how can I fix it?

I am new to Unity. I have searched but I couldn't find any answers on this. Here is my code: ...
0
votes
1answer
21 views

Second input not working when using 2 virtual joysticks

We are trying to make 2 virtual joysticks for both sides of the screen. Movement joystick can be enabled at any pressed position of the left side of the screen and shooting joystick can be enabled on ...
0
votes
0answers
44 views

Unity: AddForce problem

I have two spheres on a plane. I'm applying AddForce to the first ball after which it collides with the second one. The weird thing is that the impulse is not passing from the first ball to the second ...
1
vote
1answer
80 views

2D snake game ( how to rotate snake's head with movement ?)

I want to know: how to rotate snake's head with movement how to make tail prefabs (body) follows head direction. ...
0
votes
1answer
81 views

Creating multiple levels in Unity without duplicating scripts

I'm trying to create a falling word typing game like z-type. I have used the code provided here I want to create multiple levels in the game, and it seems like I need to make some changes in the ...
0
votes
1answer
20 views

NullReferenceException when using GetComponent

I have a script that is attached to all the NPCs in my game. Here's what the variable declarations and Awake() function look like: ...
0
votes
1answer
22 views

Resetting The object scale to it's original size!

I have this sprite renderer in unity. I have made so that it increases it's scale. The Object is: This object is a child of empty gameObject and I have resized the parent gameObject rather than this ...
1
vote
1answer
92 views

OnMouseEnter() function stops working when I set the canvas render mode to: Camera Overlay

Basically the title says it all. I have a OnMouseEnter() function that works fine when I have the canvas render mode on Worldspace but stops working when I change it to Camera Overlay. Before, it ...
0
votes
1answer
18 views

Preventing the final segment in a linerenderer from being stiff?

I am creating a fishing pole, and have the script that draws the line -mostly- worked out using verlet physics. However, the final segment is stiff. The code follows an old Unity3D Subreddit post. ...
0
votes
1answer
23 views

Unity Word Matchmaking Validation C#

Hi everyone I am new in game development, in my first development I am trying to validate if the the words if they are match with the input, unfortunately the only word it finds correct is the last ...
0
votes
0answers
22 views

Rendering fibres in Unity

I would like to make this is Unity. How to to setup the script so that Unity could render such with gradient color/material as fibres? https://portsmouth.github.io/fibre/ ...
0
votes
0answers
5 views

How to use LeanTouch's RequiredSelectable on Multiple GameObjects that have not been spawned on hierarchy

I have a list of items of Prefabs made from GameObject[] and manually inputted on inspector (element 0,element 1, etc). I am using LeanTouch to allow my prefabs to be rescaled, rotated and translated(...
0
votes
1answer
32 views

unity input controls

so im going through the roll a ball tutorial for unity and ive gotten though setting up all the controls to allow my ball character to move around the space ive built. but the tutorial says nothing ...
0
votes
0answers
11 views

How to fix 3D AABB Collision not working on corners?

I'm currently working on a minecraft clone and right now trying to implement player to terrain collision. My approach is to get the blocks which the player might collide with through the collision box ...
3
votes
1answer
40 views

Calculate angle between player and end point

I have such question: how to calculate angle between player and end point? Things, which i have: Player. I have X, Y, Z position of player and his Z-angle (0-360) Endpoint. I have only X, Y, Z ...
0
votes
1answer
15 views

Unity | Camera - Follow target with view port point's offset from center

Some additional remarks before I address the issue: How Viewports work in Unity: Whatever the dimensions of the screen's rect, the viewports coordinates are mapped in normalized coordinates, where 0 ...