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
5 views

Button Press Detection not working while detecting collision

I am trying to make a sign that brings up a panel when you press Enter while the player is over the sign. The code I have written is: ...
0
votes
0answers
8 views

Code for making Material offset follow Bone transform not exactly working

In my game, I have an Eye Bone that is constantly moving. I'm trying to make a material attached to the eye (pupil material) move in relation to the Eye bone's transform. This Script is indeed ...
0
votes
1answer
6 views

Why is this MeshRenderer null?

The following line fails in my class: MeshRenderer nRenderer = _Sphere.AddComponent<MeshRenderer>(); This is the entire class. All works except the ...
0
votes
1answer
6 views

How do I create a sphere by script?

I want to add a sphere at runtime via script. I have the following code which compiles fine. At runtime however, no sphere is added to the scene. I have attached the debugger to the script, and I ...
0
votes
0answers
8 views

Unity Serialization depth warnings

I've got this class to store spells for my game ...
0
votes
0answers
7 views

How to work with a scene objects in batchmode?

I had an object in first scene, with DontDestroyOnLoad parameter. And when the second scene (void Start ()) loaded, I searched for this object through GameObject.Find(). But this function works only ...
0
votes
1answer
22 views

Angle object only in the X axis

I'm trying to code a turret to angle towards a target, where I have one part of the turret only rotating on the left/right, and I want to animate another part to only angle up/down. I've got the left/...
-1
votes
1answer
11 views

XNA's SpriteBatch resizing is not sharp as i use it [duplicate]

I draw a TiledMap with TiledSharp and i've introduced a resize factor when drawing, that looks like this: ...
0
votes
1answer
30 views

Is it possible to work out rotate in degrees per second based on this rotate logic?

I have this code to rotate an object towards another at a given speed. ...
1
vote
1answer
29 views

Is an iOS development license with Unity free?

I'm coding in Unity Personal and I'm going to try to put my game onto the App Store (through the Unity --> XCode --> App Store process). In the past, Unity has charged money to get a iOS license for ...
0
votes
1answer
8 views

Reduce emission of sphere object with HDRP material

I have a material which I have assigned to be used on a sphere game object which acts as stars. This is what the settings are set to: And this is what the Game View looks like: I have also tried ...
0
votes
0answers
6 views

Start C# script when imagetarget is detected for Vuforia+Unity

I have a script like given below which implements spirral motion of a sphere to the center (0,0,0). I want the script to start only when the image target is detected, however in my project it starts ...
0
votes
1answer
20 views

Rotating projectile in direction it is moving

I am using a parabola curve to launch my arrows: ...
0
votes
0answers
15 views

Display/hide image with zoom in/out

After spending a while looking through the forums, I haven't been able to find a thread that deals with transforms on an image. Essentially, what I'm trying to do is display and hide an image at the ...
0
votes
0answers
9 views

Coroutine problem, I don't know what's happening [duplicate]

Calling function. ...
0
votes
1answer
30 views

2D player controller moves to the left, but not to the right

I wrote a C# script to control a 2D player, but the script is not fully working. When I press the right arrow/d key to move the player is not moving in the right direction, but I have done the same ...
0
votes
1answer
36 views

Touch goes through UI objects on mobile

I know this question has been asked a lot of times, and I have tried the solutions that were provided and I still have no valuable result, so I thought...maybe a new set of eyes could help. I have a ...
0
votes
0answers
16 views

Coroutine different behaviour when called from another script

I am quite new with game dev, specially with unity. In order to understand how it works, I decided to start small with a pong game. I have a Ball script, which in the Update() method move the ball ...
0
votes
1answer
17 views

Getting array of points shaping curve from 2 vector3 points

What I want is to get path for DoTween method DoPath(), which as a parameter expects array of vectors shaping the direction of the path. I googled some stuff and found out nothing. Just think bezier ...
0
votes
1answer
79 views

How to pass an argument with ref keyword to a local funtion/ how to work around it?

Unity 2019.3 I am writing a few extension methods to make my life a little bit easier, but this one is bogging me down. I am loading stuff with Unity's Addressable system, and I would like use it by ...
0
votes
0answers
16 views

Check if Animation State exists before playing it

In Legacy Animation Component of Unity Engine, I want to check if a specific Animation Clip exists in Animation Componenet, or not. ...
0
votes
1answer
13 views

Touch input not working well for mobile game made with Unity 2D

I made a simple game in unity where the user taps their phone screen and the player jumps up. When I test it on my phone (not sure if this matters but it's a Samsung s9+), I tap the screen and usually ...
0
votes
0answers
18 views

How to rotate a rigidbody with a Pid controller

I would like someone to describe me how to use a PID controller to rotate a rigidbody with AddTorque to a specific position. (like a spacecraft that rotates the Y axis of rotation towards Camera....
0
votes
0answers
22 views

MonoGame/Xna gamepad inputs and joystick

I've been around xna game development since very recently, and I'm actually developing a sort of Library for my games. But then I want to make an enemy with default Player settings for keys layouts ...
0
votes
0answers
21 views

Singleton GameManager - instance loses refefrences after scene load

I've been looking around sample of a singleton gamemanager, like this from Unity's own page ...
0
votes
1answer
24 views

List<T>.Contains(T) Method seems to return true for substrings? I don't want that

so I need to check a List of strings belonging to an AudioManager script, from another script, to see if it contains a specific string. Accessing that List wasn't hard. What's surprising me is that ...
0
votes
1answer
18 views

Change item rotation axis in inventory item visualization

I'm learning unity and i'm trying now make an inventory, i made a simple interface, and now i'm trying to make a item visualization. I look for some codes from web and i found this one: ...
0
votes
2answers
11 views

Instantiated prefabs dont trigger ontriggerEnter while prefabs created not on runtime, do

I am new to unity and trying to make a bouble trouble game. I have enemy prefabs with BoxCollider with is triggered checked. I also have a shooting script. when I am trying to instantiate the enemy ...
0
votes
1answer
100 views

Why don't we assign a class for each gameobject type in unity?

I used to create games from scratch with C++. There, people would create a "class Bullet", and add functionality to that class so that we can instantiate objects of class Bullet at runtime. However, ...
0
votes
0answers
10 views

Converting 3D to 2D (A* pathfinding)

I am following Sebastian Lague's A* pathfinding series, and I am on the episode where he explains path smoothing: https://www.youtube.com/watch?v=NjQjl-ZBXoY&list=...
0
votes
0answers
11 views

How do I select my platform and move them in a specific place in gameplay?

I saw this game called TaniNani and I was amazed by the concept of the game and I would like to try to replicate it! My goal is to let the player hover on the available grid (somehow like hovering ...
0
votes
0answers
22 views

Unity 2D: Dealing damage when character is crushed between two solid objects

Whats the best approach to dealing damage to a player when they get stuck between two solid objects? For instance, I'm trying to make moving platforms that the player can ordinarily touch. It's only ...
0
votes
1answer
20 views

Making an object orbit using c# script for Unity+Vuforia

I have written a simple c# script for Unity+Vuforia. I want to create a simple sample project where an object like a sphere is revolving (orbiting) origin (0,0,0) above image target. The code I have ...
0
votes
1answer
41 views

I can’t get a teleport to work c#

I’ve been trying to make a teleport for a while and it works only part of the time. the collisions work because i put a debug.log in it but the teleporting part doesn’t work. there are no errors it ...
0
votes
0answers
15 views

Normal Animation to Stationary Animation

I downloaded an FBX file and animation in it is moving in Some directions, how I can convert it to a stationary animation so I can move the model with code? I downloaded the Animations From mixamo ...
0
votes
1answer
51 views

How to properly format classes for JSON deserialization with JSON.net for Unity?

**UPDATE: This answer has been solved and this post updated to ** I am creating an inventory system and decided to keep a master list of all the items. The goal is to use Newtonsoft's JSON.net to ...
0
votes
0answers
34 views

Making a 'Darkvision' Mechanic for a Unity C# Game, Not Sure Where to Start

I am endeavoring to make a small multiplayer dungeon crawler and would like to introduce a mechanic like 'Darkvision' from table-top RPGs. The desired effect would be that where there is some ...
0
votes
1answer
29 views

How do i make a list of generic classes?

First of all, I want mods in my game, as stated in a previous question, I want to do that via registries. Users make content known to the game in the form of 'Registering' it, then it can be used in ...
0
votes
0answers
21 views

Using an objects velocity to determine if it falling on a player will kill it [duplicate]

I've been attempting to make a falling object kill a player, but i still want to make sure the player can touch and interact with the object to move it around without dying. The code i've made so far ...
0
votes
1answer
22 views

How do I slow down my character while running?

...
1
vote
1answer
54 views

How to properly manage game music and sounds?

I'm developing a WinForms customized version of Pac-Man for a Software Engineering project and I reached the point where I have to implement music and sound effects. I used the MVC architectural ...
1
vote
0answers
28 views

How to make a character move with WASD in unity

So, I have been trying for so long to make a WASD movement script, and I can't. It has come to the point that I am even getting the code off the official Unity site. And here is the code: ...
1
vote
1answer
37 views

Detect which tile in a tile palette a player is colliding with

I have a megaman-style platformer that I've been working on for a while now. I'd like to have my scene set up so that when a player interacts with certain tiles, it will have some sort of effect on ...
1
vote
1answer
34 views

Moving a GameObject to a position, waiting, and then moving it again

Hello hello :) Ive been attemping to move a platform (a door basically), and it has partually worked. What works so far is i can move an object from A to B and wait, however it will not move it ...
1
vote
0answers
14 views

Drawing rectangle around a target on screen

I am just started with Unity and C#. I need in my work to do rectangle on a scene. I have a 3D scene, say some warehouse and there is an object. Camera is animated and moving towards the object. Is it ...
0
votes
1answer
17 views

OnCollisionEnter2D and OnCollisionStay2D not detecting anything or being called unless i turn off 'Is Trigger'

I was attempting to create a simple button prompt where when you are inside a 2d box colider it will give you the option to press the button within that range, below is the short code used to test ...
0
votes
0answers
24 views

How to do draw a “visibility polygon” in 2D top-down Unity? [duplicate]

I've made a very simple 2D top down prototype with Unity. Now I want to expand the thing and add a feature where objects change when the player looks at them. So I have to add a visibility polygon ...
0
votes
0answers
17 views

Whats the best way to make my Unity game moddable? [duplicate]

Basically the title. I'm building a game with several NPCs and complex systems, and I want it to be nice and modular for modders right from the beginning. So far, I have looked into: Asset Bundles, ...
0
votes
1answer
16 views

Unity: AddForce in transform.forward direction not working as expected

I am building a very simple car-driving game in Unity. I have a Player object, which looks like this: As you can see, I have a Rigidbody2d component attached to this object, as well as a script, ...
0
votes
0answers
19 views

Getting a automatic button created in a map by line-art-detection

So I am trying to build a game based off on a real-world map. I have a pretty map and have got all the graphics needed cleared out. Now, the problem is how do I make a clickable button inside the ...

1
2 3 4 5
136