C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.

learn more… | top users | synonyms

0
votes
0answers
11 views

How to simulate airplane maneuvers?

This could be a silly question. I would like to pre-set some computer pilot aircraft maneuvers (so , a sort of AI). I would like to random generate airplane maneuvers like this Is this type of ...
-1
votes
1answer
22 views

Make Float Hindi (Devanagari)?

Whenever the game sessions ends and the Game Over scene is loaded, the score is stored in this float, which is in another script that I do not have on here: gameOverScore How would I get ...
0
votes
0answers
15 views

CS:GO - querying the server for exact player stats, round, money

How does a website like HLTV scrape all the server data, for example: kills, deaths, ADR, etc. I've been looking at valve's server queries, and their packets return kills/deaths and duration. I'm ...
0
votes
0answers
11 views

How do I trigger certain timelines to play/stop/smoothly transition based upon interactions in Unity?

I'm trying to use timeline to play an animation for an object, then when the player clicks on another object with their mouse it plays the timeline animation for that and also plays a closing ...
1
vote
0answers
45 views

Why don't variables in a script on a prefab clone store runtime changes?

I have a building prefab. There is a simple script attached to it that allows me to store unique data for each prefab instance, such as address. There are hundreds of clones of this prefab. The ...
0
votes
0answers
10 views

How can I access my button from another scene

Recently I have been making a game with a level menu, where you start at. Once you have completed that level (which is another scene) it will take you back to the main menu and allow you to use the ...
1
vote
3answers
47 views

Update and FixedUpdate together

I know some differences between Update() and FixedUpdate() and recently I have used both functions in one script. The code is working, but I have a question: Does using both of these functions cause ...
2
votes
1answer
21 views

How to place an instance of Editor Window in screen center?

I want to create an instance of Editor Window by using CreateInstance or GetWindow. And I want to place it in center of the screen (or center of Unity). I didn't find any methods in Unity Engine that ...
0
votes
0answers
39 views

Problem when try to access the gameobjects inside the if statement

new member here. Somehow I have trouble accessing the if statements when both NewComponent and Component objects are present in the scene. Apologize for this long script. void FixedUpdate() { ...
0
votes
1answer
55 views

Unity Mathf.Atan2 algorithm complexity

using Unity5.5.1f; using C#; So I have a circle (2D) divided equally by 16 directions, and I also have a direction V which is different from the other 16. In order to know which direction is the ...
0
votes
0answers
13 views

c# Sharpdx rendering outline for mesh

Here is a code from source: http://www.flipcode.com/archives/Object_Outlining.shtml outlined red mesh is exactly what I want. glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); // Render the mesh ...
-3
votes
4answers
46 views

rotate object 0 to 90 with speed 1 then wait then 90 to 0 degree with 1 speed unity c#

i want to Rotate my object 0 to 90 degree with 1 speed --> then wait for 3 Sec ---> Then Rotate again 90 to 0 degree with 1 speed --> Then wait for 3 sec i need above process in loop i m success ...
0
votes
1answer
26 views

Make Dropdown adhere size of its contents

When Dropdown is placed inside a panel with ContentSizeFitter/LayoutGroup with preferred size set, it appears to take just 10x10 units, no matter what the contents are. How can I make Dropdown's ...
0
votes
0answers
12 views

How to change Scene in Unity for SteamVR using UI buttons?

I want to make an VR application in SteamVR using unity in which we have some UI buttons which on clicking using some VR trigger give a new scene. Currently have this script to change the scene but ...
0
votes
0answers
30 views

Unity 5.6 NavMesh update at runtime

I have a game where you can build houses (multiple) at runtime. However this creates a problem because the Navmesh is not being updated which means that my agents (humaniods) are unable to understand ...
1
vote
1answer
36 views

Why is this null?

Every enemy object has an ItemDrops script and every item has a DisplayItemLabel script. In SpawnItem(), you'll see that I'm trying to set itemNameText.text to "hello"; I'm using a string literal to ...
0
votes
1answer
14 views

Read from OpenGL texture to Bitmap in C#

I want to read a texture pixels from texture id (associated with some FBO) to bitmap object in opengl (opentk) in c# But it throws an exception says: System.AccessViolationException occurred ...
0
votes
0answers
29 views

Always getting the origin value of Vector3 position from class methods

I am new to Unity and C# and trying to implement a virtual Joystick in my game. I don't know what is going wrong why I am always getting Vector3 as (0.0,0.0,0.0) when I debug vector3. Here is my code: ...
0
votes
1answer
18 views

Travel over step angle

http://www.gamasutra.com/blogs/AdamWinkels/20140220/211306/DevLog_7_Learning_How_to_Walk.php Following the link above I have been able to get my character to move and rotate very smoothly over angled ...
-1
votes
0answers
28 views

Unity Game Development - tracking points on screen to make a visual representation [on hold]

I'm new to Unity. I am making a 2d shooter and need to track the 'hits' on the screen to create a visual map at the end. The game features an object appearing randomly on part of the screen which ...
0
votes
1answer
29 views

Question about references

I have an enemy game object and an item game object. Enemies have an ItemDrops script attached. Items have a DisplayItemLabel script attached. Attached to each enemy: public class ItemDrops : ...
0
votes
1answer
20 views

2D stop on collision. XNA

So, this is the code I have right now. if (keysPressed.Count() > 0) { switch (keysPressed[0]) { case Keys.W: { ...
0
votes
1answer
32 views

Enemies and item drops issue

Disclaimer: I'm relatively new to developing games so bear with me. In my scene I have enemies and when they die, they drop items. No matter which item is dropped, the same prefab (the physical ...
3
votes
1answer
41 views

How to access arrays of prefabs and other properties through the inspector in a given hierarchy

The script below is added to an empty game object WeaponGroup, which can be populated using the editor. I have made a new game object WeaponGroups which should have a script SetupWeaponGroupsScript. ...
1
vote
1answer
89 views

How should I deal with different enemy types? [on hold]

I'm making simple space shooter game for Android in Unity. I want to have different types of enemies (different weapon, stats, movement schemes) and I'm not sure how to do it. I'm quite new to ...
-1
votes
1answer
53 views

How do I storage only integers value on a Vector3?

I need to figure out a way to lock or avoid Vector3 storage float numbers. I do need save only integers because each integer represents a place on an array. I don't wanna my objects moving with float ...
0
votes
1answer
46 views

How to store an array of prefabs together with configuration parameters

I have attached the following script to a number of weapon prefabs: public class WeaponScript : MonoBehaviour { public enum Direction {Right, Straight, Left}; public Direction weaponDir; ...
2
votes
1answer
92 views

Constraining camera bounds within bounds based on Unity UI object dimensions

I have a perspective camera which has bounds which I wish to constrain within larger bounds. All the bounds are calculated in world space. The code for containing the camera within the constraining ...
0
votes
1answer
40 views

How to instantiate an array of Prefabs in C# Script

Sorry if this sounds quite primitive, I am new to Unity. I am trying to instantiate an array of prefabs, but it doesn't seem to appear when I run the game. Firstly I created my block prefabs, then I ...
3
votes
2answers
74 views

Stopping a reflecting raycast/linerender laser

Update: Doing some more experimenting... it's not the early break that's causing the problem in the slightest. It does the same thing if I set the reflections to more than 2 and have no if or break in ...
0
votes
0answers
33 views

Stick character to surface

http://www.gamasutra.com/blogs/AdamWinkels/20140220/211306/DevLog_7_Learning_How_to_Walk.php I am trying to replicate the work in the above link as best I can but some stuff has to change since its ...
3
votes
1answer
103 views

Simple wandering chicken AI in Unity

I have a very minor NPC. A chicken. My target is for it to move a random amount, in a random direction for a random time then wait a random amount of time before moving again. Like a chicken. But I do ...
1
vote
1answer
35 views

SerializeField UntiyEvent not properly saving modifications in EditorWindow

I'm making a node editor in Unity using an EditorWindow, I'm currently trying to make it so designers can add their own methods to a node using serialized UnityEvents; but I haven't been able to get ...
1
vote
1answer
39 views

How to Create A Vertex Buffer Object from Wavefront Data

I have written my own Wavefront Model parser, which I have been using for quite some time to render meshes in immediate mode. However, I now wish to upgrade my system to Vertex Buffer Objects. I was ...
1
vote
1answer
39 views

MonoGame “couldn't find a default importer” for .txt file?

I'm trying a solution in MonoGame to create levels from a .txt file, but the pipeline tool fails when trying to build the Content.mgcb correctly: ❌ Skipping HighResolutionContent\Backgrounds\...
0
votes
1answer
24 views

RectTransform Button Start shaking with Vector3.MoveTowards()

I have a RectTransform Button that i want to make it move to a de-terminated vector3. To move the button i use this code (it is inside Update()) int i = -1; foreach (RectTransform ...
1
vote
1answer
41 views

InvalidCastException when instantiating a prefab on the network using Photon

As stated in the title, I get this error when I try to instantiate a game object using Photon: InvalidCastException: Cannot cast from source type to destination type. NetworkingPeer....
0
votes
0answers
18 views

How to correctly implement the command and state patterns together in Unity?

How to correctly implement the command and state pattern together in a game? namespace MarioGame { public class BaseClass : MonoBehaviour { MoverScript moverscript; protected Transform ...
0
votes
0answers
44 views

Error Compiling Shader in Unity

I bought an assets package from the store, and tried applying it to my "World Bender" shader. Sadly, all the assets have shaders. I tried including both scripts in the same shader, but I ended up ...
0
votes
1answer
33 views

Trying to make a button in Unity which spawns a character each time it's clicked

I have a simple 2D game, I want a UI button to respawn the character (if it's not already present). The first problem I encountered is that the button only works once. I can't go any further before I ...
0
votes
1answer
45 views

Problems with the Unity text field

Let say I have this list and currently there are three animals inside the list. These names below are displayed on the text field in the scene. Cat Bird Goat If there is a new animal is added to ...
0
votes
1answer
63 views

Unable to Execute code in (what i expect to be) the correct order

I have become completely stummped on this. I have a login screen i have created, i have everything working except 1 thing. When i click "login" i want to hide the Login screen object (wm....
0
votes
1answer
37 views

nullException issue [duplicate]

I have a problem when I was trying to change a state within my character. I wrote the code below public class playerController : MonoBehaviour { private CharacterController characterC; private ...
0
votes
0answers
20 views

How do I convert a sliced image into a grascale image that is useable with Unity terrain using “System.Drawing”

I have managed to slice a large height map up, based on the segmentation of my terrain generator. In my case; I'm generating a 5x5 128 unit grid of terrain. I decided to take a 5125 x 5125 pixel image,...
1
vote
1answer
142 views

Why are my network players only able to shoot horizontally in my first person shooter?

I am quite new to the Unity community, but I can code in C#. I am testing Unity networking using a standard FPS. I am stuck while testing out multiplayer shooting, not using raycasts. The host can ...
1
vote
2answers
49 views

Why can I sometimes access Static objects' elements and sometimes not?

I'm making a game in Unity and I learned to make my Player object static for reference by other objects quickly and easily. So I have a "public static Player player." I remember when I first made this ...
0
votes
1answer
55 views

MMO Server with C# asynchronous sockets performance

I have developed a 2D RPG MMO client / server. The server is developed in C# with asynchronous sockets. It is a pretty simplet implementation. The server gets the client's input / coordinates and ...
0
votes
1answer
31 views

Unity accordion UI

I downloaded the accordion from the unity forums and I'm trying to add a button to it. issue is with the vertical layout group. when any UI element is added the layout will automatically go vertical ...
3
votes
2answers
155 views

How to create a grid movement like the oldschool snake game?

I got 2 problems with the game, I don't know how make my GameObject (snake head) move based in a grid for some reason I don't know it moves freely on the screen. The tail keep instantiating above ...
-1
votes
0answers
35 views

how to make a cube to change color by clicking a button in unity? [duplicate]

i used this below code to change the color of a cube if i pressed a button. but its not working.i have added this code to cube and in button i have attached this script and function. if i pressed the ...