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

How would I swap a character when a player touches a collider?

I wrote a simple script to attempt to do this and I created an empty game object and applied the script to it and dragged both of my sprites into my script and I receive no errors but nothing happens ...
0
votes
0answers
25 views

how can this random scene code run well when it is reloaded?

I have a code for random scenes, the scenes that I have are 10 randomized scenes, but when I reload the scene there is only one scene. ...
0
votes
1answer
29 views

How to reset the score to 0 when reloading the game?

My scoring system uses DontDestroyOnLoad to persist between scenes: ...
0
votes
1answer
19 views

Unity FPS style turning

I have this code: ...
1
vote
1answer
18 views

Unity right mouse drag turn

How would I use my right mouse button to turn a player character in unity, while only turning in the direction and speed of the drag? Not sure if I'm meant to post this here or stackoverflow. EDIT: ...
0
votes
0answers
9 views

Help with Enemy pursuit script or follow player, endless runner type

Someone Should help me with a Script or code to integrate enemy to pursue player and then lag behind in speed, and if player speed reduces, it will catch up, like the normal enemy purse mechanics ...
0
votes
3answers
42 views

How to add collision to this script in Unity

I Want to be able to have collision were my player can't go through objects with colliders un Unity but I don't know how to make that happen, can you please help? ...
0
votes
1answer
23 views

Is it ok to return a call to itself inside a method that has a return type?

Hello all I am making a little blackjack game in Unity. Although these classes don't actually use Monobehaviour or anything just yet. I have this method and I'm not sure it will work like this or not....
0
votes
0answers
7 views

Export GameObject to IFC file fomat

I have some max model (fbx) object and some unity primitive objects. A user can view it in a unity player. Now i want to provide a feature to end user that they can export the unity game object to ...
0
votes
0answers
17 views

Animate character to walk beside NPC or object

I found a tutorial on youtube which is interacting with NPC and Items. My question is, how can I animate my character once the NPC or item is click. I want the character to move forward to the NPC or ...
0
votes
0answers
13 views

Unity C# Help With Distance Based Spawner

I am having issues creating a spawn system that relies on the distance of the last object spawned from the spawnpoint. I do not want to use a timer to determine when the next object is spawned but ...
0
votes
1answer
39 views

Enemy doesn't fire at player

My script looks pretty good but it says Target variable has not been assigned value. ...
0
votes
0answers
25 views

Wave spawner and word length

I'm trying to create a falling word typing game like z-type. I have used the code provided here : https://github.com/Brackeys/Falling-Words-Typing-Game In the WordSpawner.cs file, I'm trying to set ...
0
votes
2answers
61 views

Fire at enemy script doesnt work

I need my enemies to fire at me. I have a script and I think all is correct. I couldnt figure out why it doesnt work? ...
0
votes
0answers
19 views

How can I make this object Instantiate in a specific position?

I have a really simple script that instantiates objects when the "enemies" object has 0 children, it should spawn in the position of EnemyT, but they fall through ...
1
vote
2answers
28 views

LOD culled gameobject still interacts with raycast

The camera is sort of top down and the player can move objects around, rotate them, delete them etc. I use a raycast to check what was hit when the player clicks. But some objects are culled by the ...
1
vote
0answers
37 views

Unity : How to detect if a UI button is pressed down?

I want a UI up arrow button to be able to detect if it is pressing down. It is a child of a canvas in a 3D scene. My target platform is webGL for both desktops and mobiles. I coded not only the ...
0
votes
1answer
31 views

Is any Update() called always first than any LateUpdate() from other scripts?

If a script is called at a specific moment in the script execution order, will every LateUpdate() functions from the rest of the objects work after that Update()? The documentation isn´t clear about ...
0
votes
2answers
40 views

How would I apply force to a bullet in 2D?

I wrote the code below in order to try to get a bullet to fire at a specific angle for my top-down shooter. However when I press space the bullet just spawns in front of the game object despite it ...
0
votes
1answer
26 views

Unity: how do I make an input only available to the code?

I have a simple function attached to a button. I then decided to change it by adding an input. The problem is that the function won’t run unless I specify the input in Unity via the inspector. I don’t ...
0
votes
2answers
24 views

UNITY || How to access the “exit transitions” of the current played clip from the animator?

So, I have an animator , i can access it. But from there I have no idea how to access the clips inside. I need to access the transition of the clips. I got as far as accessing the object of the "...
0
votes
0answers
9 views

Unity, animation starts too fast

If I start the game my animation is like 20 times faster then I set it, after I move direction and back to the idle pose where the animation is set, it turns back to normal speed. I didn't changed the ...
0
votes
0answers
21 views

Tips on making simulation for farming based game [closed]

I am currently developing a 2D farming game in Android and I can say that it is going pretty well. Some of the functions I figured out to work were: 1.) Generate a grid depending on user's input. 2.) ...
0
votes
0answers
44 views

Unable to change value of Input Field text component

Learning about UniRx and ran into a seemingly small problem that I can't seem to get my head around... ...
1
vote
2answers
73 views

Structuring game narrative. Handling NPC, Quest, General Dialogue. Is Json/XML the right way to go? Or any other solutions?

Hello guys I'm try to make some games that have more to it than just simple high score scrolling shooters etc. I'm trying to design my own systm of handling narrative. I want to be able to place NPC'...
0
votes
1answer
9 views

Get the mesh Project Plane on Click and calculate its area

Here is the excerpt of my script which is calculating the surface area and face area of a mesh on OnMouseDown Event. ...
0
votes
0answers
30 views
0
votes
2answers
34 views

How To Destroy/Deactivate one enemy without affecting other enemies of the same type?

In my game, you jump on zombies'heads to squash them. Currently I'm only able to have one zombie in my game. When I add another (duplicate or drag from prefab), then run the game, I can squash one ...
0
votes
0answers
11 views

Google Protocol Buffers 3 Builders in C#

I am developing a game in unity3d. I am using google's protocol buffer 3.6.1 compiler to compile .proto files in c# but its not creating its builders. does builders removed ? whats the new way to ...
0
votes
1answer
41 views

How to check for mesh overlap?

I'm creating a level editor in Unity. I need to detect when an object is intersecting another as I don't want to allow the user to place an object when it is colliding with something else. In the ...
0
votes
1answer
19 views

Object activate it self without script order?

I have strange thing here in my script. In this script clock_time turn active lamp object one by one. Where Lamp object turn off after 3 seconds be anther script. If clock time reach 120 or higher ...
0
votes
0answers
18 views

Load Textures Stored as Embedded Resources?

I am currently trying to re-write some of my loading methods and have come across the methods that load textures. I would like to store the texture files inside of the project instead of on the hard ...
0
votes
0answers
10 views

Smoothing noises with different amplitudes (Part 2)

Well, I'm continuing this question without answer (Smoothing random noises with different amplitudes) and I have another question. I have opted to use the contour/shadow of a shape (https://...
0
votes
0answers
27 views

Stencil Rendering?

I may not be searching this properly, but I can't seem to find a decent tutorial on what I'd like to achieve. The only thing that seems to be close is this tutorial on reflections using the stencil ...
0
votes
1answer
28 views

How to stop all character movement when jumping against the side of a platform?

My Sprite is Moving against a platform. I have a script and an unusual one (that's what one of the member said.) My isGrounded isn't using any rayCasting. I didn't have any problem with it but when I ...
0
votes
0answers
8 views

How can I get ping value from Photon Cloud?

I am trying to get ping from Photon Cloud but it always shows 0. I use method GetPing(); ...
0
votes
1answer
19 views

GameObject.FindWithTag throwing weird errors

I've got 2 first person controller scripts, one that handles functionality for basic movement, the other handling looking around. I also have a "CursorLockManager" script, that handles the cursor ...
0
votes
0answers
35 views

How to calculate faster how much a collider is going through?

So I think this may be an overkill, but am casting two different rays for a single collision. This is because the physics´ system in unity detects collision contacts in the wrong place when ...
0
votes
1answer
99 views

How to calculate the surface area of a mesh

I am looking for a way to calculate surface area of a 3D mesh object and found this code from a Unity forum: ...
0
votes
0answers
15 views

Keeping child GameObjects disabled on OnTrackableStateChanged

I'm making some kind of "board game" with AR. The idea is the player finds the ImageTarget, the board appears, and then the game begins. For this, I have a father ImageTarget and a "MapRoot" ...
0
votes
0answers
23 views

Switch screens with MonoGame.Extended - ScreenGameComponent

I'm trying to piece together a very simple game foundation based on MonoGame.Extended from the documentation and tutorials I can find on the internet. For starters, I wanted to setup the different ...
0
votes
1answer
14 views

Animation Length to Integer

‏‏‎ Currently, I have a script; more specifically for weapons. It handles animations, and the animations are being played and then stopped (once they're finished) by co-routines. I have variables ...
1
vote
2answers
123 views

How to make a Blend-Effect like yomawari did?

I would like to know, how to make that effect, I have seen in the game named Yomawari. The little girl has a lamp and its cone revals the dark spirits around her. But only if they are in the light. I ...
0
votes
1answer
44 views

Remove hidden values within string

I tried removing the Unicode Whitespaces in the string using words[len].Trim() but still there's still an extra character. Every letter represents the coordinate ...
0
votes
0answers
47 views

the snail makes a weird behavior when the player push it

I have a problem when I push the snail when she is stunned and at the same time when the player moves to the snail, the snail makes a weird behavior. could you help me solve this problem or just tell ...
0
votes
0answers
10 views

Animation type changed from Generic to Legacy; animation clips now irretrievable

I imported an .fbx file with the 19 animation clips: Originally, the animation type is Generic, with the following properties: ...
0
votes
0answers
46 views

How to properly squeeze an object when is being pressed based on percentage of collisions in relation to scale?

Am trying to do this: How can I "squeeze" a game object when it is pressed between two others? Which has anwsers, but with some issues, like not lerping back to original scale or not ...
0
votes
1answer
16 views

Contracting Unity EditorWindow UI

How can I make scalable(contracting) EditorWindow UI(not in-game UI) like in inspector example?