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
0answers
10 views

Q: 2D cone and rectangle collision detection

I'm working on a 2D RPG game and now I need to detect if players ability collides with enemy rectangle hitbox. Currently I have this code that detects if a point is in cone, but I need to modify it to ...
0
votes
0answers
12 views

GA Measurement Protocol without Firebase

I was successfully using Measurement Protocol for my websites and web apps to gather analytics data. Now I'm trying to implement it in my game, but nothing happens. Debug url gives a valid response: ...
0
votes
0answers
24 views

why does Physics.Raycast always return my player game object instead of the object I clicked?

I have 3D world. I want to detect when the player clicks on a game object in the world. In this image, I have 2 objects I want to detect mouse click on. The white sphere does have collider on it. The ...
0
votes
0answers
15 views

SetTextureOffset in meter per seconds speed

I have this code snippet that faking the tiling offset speed. Now i want to set the speed in terms of meter per seoconds. how to divide or multiply that i get a number which is meter per seconds: <...
-1
votes
2answers
22 views

Unity: RigidBody2D, Trying to Set rb;

So for Unity I've been trying to to do the code line public RigidBody2D rb; I've followed the gmetrix unity programming course and they do that just fine with the ...
0
votes
1answer
31 views

How to add force on an object when it landed on the ground?

when i add the force it jumps up and disappear after pressing the up key.I want it should addForce only when it is on the ground position.
2
votes
2answers
29 views

Same noise generator for C# and Javascript

I'm writing a 2D web racing game with procedural generated maps using perlin noise(as a university project). The server is written using C# and the client using Javascript. I've developed procedural ...
0
votes
1answer
49 views

How to place a camera so that it always fits a plane?

I have a plane that can get its scale changed during the game, and I want to make the camera view it completely every time the plane has its scale changed. The only camera is set to perspective ...
0
votes
1answer
13 views

Unity BoxCollider2D causes motion to be exponentially multiplied

I have a player and an enemy square for my 2D game (technically it's a cube, but it's rendered as a 2D character). I have a RigidBody2D attached to the player and the enemy each, along with a ...
0
votes
1answer
43 views

How do I get the size of a Plane in pixels and set it multiplied by some factor to be the size of a Sphere?

I am doing an attempt to make a 3D snake game, as an experiment but I am still a beginner. I have a Sphere that I wish to dynamically resize to be, let's say, the ...
0
votes
0answers
14 views

Unity - transform.RotateAround change to bigger circle

I am making a game in Unity using c# where the player object is rotating around the world origin. I am using transform.RotateAround to rotate around the center and I want the player to be able to ...
0
votes
0answers
26 views

Logarithmic Depth buffer sampling

So i'm trying to sample a logarithmic depth buffer enconded with this formula: Depth = (log(C * w + 1) / log (C * 1000 + 1) - 1) * w How can I get back z from ...
0
votes
1answer
39 views

The camera does not capture movements in z-axis

I want to make a simple drag and drop card in Unity, where the card pops up a bit towards the screen when the drag begins (lifting effect), and then drops down back on the table when the drag ends. ...
-1
votes
0answers
30 views

insert multiple vectors into a single method [closed]

For example, I have this lerp where it takes a single array of type vector3. let's suppose I have two arrays in vector3 position and position2. I was wondering if you can insert some of them into my ...
0
votes
0answers
24 views

Animating a pendulum by using equation of motion

I want to animate a simple pendulum by using differential equation of motion in Unity3D $$\cfrac{d^2\theta}{dt^2}= -\cfrac{g}{l} \sin(\theta) $$ There is a coding challenge video to simulate a "...
-1
votes
0answers
29 views

HLSL Directional light with shadows

I'm trying to lit a scene with a directional light and also cast shadows from it. My HLSL Shader looks like this… ...
1
vote
1answer
34 views

Transform check should return null, but returns as initialized instead

In my Player script, I initialize my FirePoint transform using GameObject.Find in the Awake function. In the editor, I purposely misspelled the name of FirePoint to test if the null check inside of my ...
0
votes
0answers
76 views

How can I reference a public static variable?

...
0
votes
0answers
21 views

pushing rigidbody with force to match mouse position [duplicate]

i'm making a game in which the player character, a 2d rigidbody, is controlled by the user's mouse dragging them. i originally made it so that the player character's position was made the same as the ...
0
votes
1answer
42 views

curve of animation in C#

I think that the animation curves in Unity lack the fact of being configurable because they are only chosen with a certain type (no sinusoidal function) and adjustable with handles. How in C # create ...
0
votes
1answer
38 views

How can I fix a GameObject along one axis only when it is part of another object in Unity?

Hello I have an Object player and inside player, I have an object Boundary which is supposed to follow the player as he moves up or down only? (As the player moves right or left I don't want the ...
-1
votes
1answer
43 views

(C#) Need help with Shuffling a list

I'm making a deck building game in Unity and need a way to shuffle a deck of cards in a list. I've tried to use a version of the Fisher Yates Shuffle, but It's not working. I'm not given any errors, ...
0
votes
0answers
29 views

HLSL Xna Deferred light issue

My point lights seem to have problems when the camera is far away… is it the depth map? Anyway i'll show you the code Here is my GBUffer fx : ...
1
vote
1answer
34 views

How can I insert a prefab instance programmatically inside the Canvas, in the bottom-left corner of the Canvas?

I am trying to create the Snake game in Unity, based on this video tutorial. I have also viewed this tutorial. I have created the new project with the 3D template and manually added the Canvas. I ...
0
votes
0answers
23 views

Tilt car to accomodate for larger Tire

I would like to rotate the car so that the front wheels are touching the ground without using physics. As you can see i want to rotate the car by angle a, but making sure that both tires are touching ...
0
votes
1answer
39 views

2D party follow the leader in Unity?

I am attempting to make a 2d side-scrolling platformer where the player collects other characters as they advance through the levels, like you would in a classic top down rpg. However, I am having a ...
0
votes
1answer
38 views

Visual studio alternatives for unity as intellisense not working

I am new to unity and unity tools for game dev are unavailable in vs community,i also tried vs code.So what are some alternatives for vs for unity scripts for a beginner?
0
votes
0answers
41 views

How do I add data to a Dictionary after I deserialize the data for the class?

I'm getting a null reference exception on "AddEmpireView()" and I cannot figure it out for the life of me. Here's the class: ...
-3
votes
0answers
20 views

Unity game with Rs232 connection, where to start?

I have to make an unity game for school, to be more specific is a board game (snakes and ladders) of 4 players using serial com rs232 connection. Problem is that I don't know where to start, our ...
0
votes
1answer
13 views

My vertex cache for reusing vertices in marching cubes algorithm in unity fails for one case, but I cant figure out what case

I implemented the marching cubes algorithm in unity and wanted to reuse vertices instead of creating new ones for every triangle. I am looping through a 3D array of points as I generate the mesh in ...
0
votes
1answer
21 views

Heir Class Constructor Throws CS7036 “No Argument Given” Exception [closed]

I'm trying to create a class that holds the data for an an attack, called Attack. I also have special attacks that have more properties, and so I wanted to create a ...
0
votes
0answers
15 views

XNA MAtrix Object rotates, scales but does not move

I have the following transform method to transform all the vértices in the buffer : ...
0
votes
0answers
16 views

Developing a menu of buttons in a ScrollView

Alright, So I'm very new to C#. Please forgive me. I'm sure this is a really easy fix, but It's been a while since I've worked on this project and I think I found the bug but I'm not sure how to fix ...
0
votes
0answers
17 views
0
votes
2answers
47 views

How do I remove the objects when it is not seen on the camera?

I am a beginner C# Developer and I am creating my own version of the "No Internet Dinosaur Game." How do I remove the Object like (Platforms, Cactus, etc.) When it is not seen on the camera?
0
votes
0answers
18 views

How can I spawn and drag 2d object from a Canvas button?

I want to create and drag an object from canvas button to scene. How can I do this?
0
votes
1answer
30 views

Unity Script and game not syncing after player respawn

I have a health system for my player that looks like this: ...
0
votes
1answer
56 views

How to create a refill system over time

I am making an energy beam firing system from a drone. In my code, I have setup a system in which the player presses and holds onto the firing button, then a countdown bar begins to countdown, and ...
0
votes
0answers
24 views

How do I fix “Invalid character '' in input string at LitJson.Lexer.NextToken ()” when trying to use JSON from URL?

When trying to use a Json file served by a url I am getting the error JsonException: Invalid character '' in input string it happens when I use this method: <...
0
votes
1answer
25 views

Unity Initializing class of a script not working

I have been trying to find a solution for the last couple of hours so please hear me out. At first I got a NullReferenceException, which I resolved(?) by initializing the class first (This is my ...
0
votes
0answers
16 views

Coroutine not working, NullReferenceException Unity [duplicate]

When I run my game and collide with my object, I get a NullreferenceException error. I went through many posts I could find on Stackexchange and other websites, but nothing helped. When I did a Debug....
1
vote
1answer
49 views

Simulate wind in a powder game

I would like to create a game similar to powder game. I've got a 2d array that stores different types of powder such as sand, water, gas, and fire. I've managed to get these to all move around ...
0
votes
1answer
29 views

Coverting byte[] from stereo to mono produces crackling in OpenAL

I'm trying to convert a Stereo byte[] to mono byte[] Here is my code : ...
0
votes
0answers
13 views

Monogame pipeline couldn't load Xamarin.Mac

I Try to use my ContentProcessor, which I wrote on a Linux machine, on a Mac but it crashes with an unexpected failure. The Pipeline Tool gives me the following It seems to be a problem with the ...
0
votes
0answers
12 views

Unity: Prevent game object from shrinking when using Scale With Screen Size

In my Unity app I am trying to draw a line between two points. For this I used a game object and set it's width to 1 so it looks like a line. I know the coordinates of the points between which I want ...
0
votes
1answer
22 views

Prefab spawning issue

I am having trouble spawning some obstacles from some prefabs. The aim is to make and endless runner (like normal) with obstacles to go through that spawn as the sprite goes up. But my prefabs don't ...
0
votes
0answers
29 views

Unity : Rotate object on touch looks weird

Touch and hold the screen then rotate object continue("Object is unity default cube") that's my operation, but when object is Rotate then it's look like weird. I ...
1
vote
1answer
65 views

Does P2P Matchmaking can make an online game without any cost?

I’m planning on making an online game. I’ve used Unity (with Photon’s PUN2), but after some research, I had the idea of instead of using a server, with ccu limit and charge fees, i could make a P2P ...
0
votes
0answers
27 views

Why the state of the duration is all the time 7 even if updating the state inside the while in the ienumerator?

I want to get the current coroutine state. ...
0
votes
2answers
40 views

Ensuring dash toward mouse position is always a consistent distance

I'm making a 2D game where the player character should dash toward the mouse position when the player clicks, but the dash is currently not a consistent distance each time. Let's say you put the ...