C# is a multiparadigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

learn more… | top users | synonyms

0
votes
0answers
34 views

The problem with the movement of the serpent (snake game)

I am a beginner,Unfortunately, the snake's movement can not write I do not understand how to do it? Do you like the idea? note:In fact, I mean, flexibility is a must have when moving in different ...
4
votes
2answers
289 views

How to impale and stack targets correctly according to the collider and its coordinate?

I'm making another simple game, a catch game, where a spawning target game object must be captured using a skewer to impale it. Here how: At the start, the falling object (in red) will fall in a ...
0
votes
2answers
205 views

Casting a directional line of which an object is coming from

I want to create a directional line ( curve / linear ) depending where the direction is coming from. In some games, similar to Angry Birds, a dotted guideline is shown to provide where the gameObject ...
4
votes
1answer
271 views

Set a 'chance to spawn' for each GameObject in an array

I have an array of gameObjects in a spawner. I want to randomly spawn these gameObjects based on a weighted chance. I want to be able to manually set in the Inspector a percentage chance that an ...
0
votes
1answer
136 views

How to stretch screen image to fit higher res monitors set to lower resolutions with Unity?

Using Screen.SetResolution(width, height, windowMode); , how might I stretch the image to match the monitor size? I've noticed this problem occurs both with this line of code and also the default ...
0
votes
2answers
101 views

How do I build a 3D array result set from a compute shader in unity?

I took this right down to the absolute most basic scenario but for some reason I can't get anything back from the GPU when this completes, could someone explain what I am doing wrong ... Here's my ...
0
votes
0answers
35 views

Game crashes when sound is finished

I'm trying to code a simple audio playback test game (which will be used in my actual project), and everything works fine, except for the fact that after the audio has finished playing, the game will ...
1
vote
2answers
3k views

Octrees as data structure

In my cube world, I want to use octrees to represent my chunks of 20x20x20 cubes for frustum and occlusion culling. I understand how octrees work, I just dont know if I'm going about this the right ...
0
votes
0answers
22 views

c# adding object collision to multiple objects

I'm trying to make a mario, platformer type game, and from following a tutorial, they've done the collision like this, but im wondering if there is a simpler way to it since I want to have collision ...
-1
votes
2answers
52 views

How can I implement Player Prefs to Save High scores in unity?

I am new to both unity and C# and facing trouble in saving and displaying the highscore.text in the game.Til now I only successfully managed to display the scoreUI and update them whenever player ...
0
votes
0answers
15 views

Effect of merging sprite

I want to create the effect of merging of colours if they are overlapping. My game is a tile-based game. For all intents and purposes, lets consider a tile from (0,0) to (1,1) in the entire example. ...
1
vote
1answer
200 views

Unity provides wrong Input value if game is started with bumpers pressed down

As the title states I am having an issue with the following. It is a pretty specific edge case but it is something I can't work around. In Unity I have created two Axes to allow me to check the value ...
1
vote
1answer
525 views

How to move rigidbody player to its facing direction with AddForce?

How can I move a rigidbody to its facing direction? I've already tried this: rigidbody.AddForce (transform.forward * v, ForceMode.Acceleration); // v is a public float which gets a new value in ...
3
votes
2answers
64 views

Stopping 3D object in place

I am at 1.2 stage (moving the player) at Unity course "Roll-a-ball" and have question: I want to add feature that stops a player and sets his new position on 0, 0, 0. I can reset the position, but I ...
0
votes
0answers
17 views

Unity Compute Resource Management

I have a n open ticket with unity about some code I have that uses the GPU to generate quads and passes them to an array on the cpu. The code in question is a little specific to my situation so I ...
2
votes
1answer
30 views

How do I include XML files in an Android build?

I have a few XML files I want to include in a build of my game, and I want to have access to those XML files in Android. How to I store and load those XML files?
1
vote
1answer
39 views

How do I call the sprite auto-slicer from a script in the Unity editor

First of all let me start with an apology. I know this may not be the right place for this question, but the good people over at stackoverflow did not answer me and neither did I get a answer over at ...
0
votes
0answers
22 views

How to compress an asset bundle and decompress it on iPad or iPhone

In have a prefab size of 2.4 mb, when I convert this into Unity Asset Bundle, the Asset Bundle is goes to 127.2 mb. How can I compress this into small size? My code is: public class ExportScene : ...
0
votes
0answers
47 views

Water reflection xna

I'm actually trying to do the reflection map for my water component, but even following the riemer's tutorial about reflection map the formulas provided doens't work. ...
0
votes
1answer
125 views

How to refresh andoid photo gallery in unity

After saving a screenshot into the folder i cannot view the screenshot in the android gallery but can see the screenshot in the folder created.Is there anyway i can see it through gallery?
1
vote
1answer
146 views

Ray & Segment Intersection

I'm writing some code to check intersection between all of a rectangles segments and a ray. It will sometimes use the Left and Right side of the rectangle as the closest face hit (face DA & BC) ...
0
votes
2answers
983 views

How to make a gameobject Scale up from another GameObject script

hi there im having a rought time with this code, trying to make a gameobject grow in scale from touching this one, and when a set amount of scale is reached destroy this game object ( the one who ...
0
votes
1answer
72 views

Simple 2.5D flight movement

I'm building a simple 2.5D Dogfighting game, kinda similar like this one: https://gfycat.com/PleasantDeterminedArcherfish for the moment my movement works like this: if (Input.GetKey("left")) ...
0
votes
1answer
793 views

Unity 5 C# - onClick.AddListener in a foreach loop using lambda expressions

I'm trying to dynamically create Unity 5 UI buttons that each set a global variable decision_id to a different value when clicked. The problem I'm having with this implementation is that they all ...
1
vote
2answers
27 views

Unity get more than 2 lines of log height

Unity does only display 2 lines in height for each log, at least with the default settings. I couldn't find a menu, where I could change this. I want to display a matrix, and I need to see the log ...
0
votes
1answer
36 views

Unity C#: Change speed when all Targets are destroyed

I have a game where a Gunner moves on a pre-set path towards a final destination. You play as a Magic Bullet that auto-fires from the Gunner's current position and can be controlled with WASD. When ...
0
votes
2answers
2k views

How do I add a gameobject to a prefab's script's public gameobject field in Unity? [duplicate]

Okay, I have a prefab with a script. It has the public field gameobject, and I see that in the inspector. When I try to drag an object from the scene into that slot, I'm simply unable to. No error or ...
2
votes
2answers
189 views

Enemy AI with Rigidbody - Floating in the air

I'm working on my enemy AI scripts and I'm using a rigidbody to have the enemies chase the player when the player gets into its aggro distance. Two of the main problems I'm having: When the game ...
0
votes
0answers
30 views

Unity websocketsharp is closing the connection directly

I got a working code, which I want to change a bit for better readability but afterwards my web socket is just closing instantly. First off, I got this code working : using UnityEngine; using ...
0
votes
1answer
45 views

Unity3D - How to get highest value for acceleration from Input.gyro

I'm trying to develop an app that can detect car acceleration, braking and cornering speed. I need to detect device acceleration. Is that acceleration high or low?. Like flo app on Google Play. I'm ...
3
votes
1answer
263 views

How to save the Mesh from an Interactive Cloth at runtime in Unity?

At the start of a scene I have GameObject called 'sheet' positioned above a 'ball' GameObject. The sheet has an Interactive Cloth component on it and a Cloth Renderer. The Mesh for the Interactive ...
2
votes
1answer
1k views

Adding materials to a Line Renderer through code? (Unity)

I have a material that I am using to add a glowing effect to my line renderer. I can add this as a 2nd material to the line to give it a glowing effect. I want to be able to add/remove this material ...
2
votes
3answers
315 views

Camera follows player but how to stop camera moving when player moves

The player is moving automatically diagonally down the screen, and I have the camera as a child on the player. I would like the camera to always be following the player (who sometimes slows down / ...
0
votes
1answer
87 views

Different game resolutions on emulator and on a real device (which has the same resolution) on Windows Phone 8

I have a big problem with game resolution, when I'm running my game on emulator (which theoretically has the same resolution as my real windows phone device: 800 x 480). I'm making the game with ...
3
votes
1answer
77 views

How do I get data from a WWW object without freezing my game?

I am using Unity 3d to create a real time multiplayer game. I have a database set up that keeps track of player statistics and what in app purchases they have purchased. I have written a Database ...
0
votes
0answers
62 views

How to convert a mouse's “On screen” position to “World” position C# Monogame

So the problem is this... I have a top down game, where you click on the screen to select which unit you want to control. You left click to select, and right click somewhere else to tell it where to ...
0
votes
1answer
288 views

How can I add banking and rotation to this object manipulation script?

I have made a drone script that allows user to move in four directions and ascend/descend. I found a nice tilt snippet which makes the thing bank when it moves. However, when I include this, the ...
1
vote
1answer
62 views

Unity2D Isometric layering

I'm developing an Isometric Game but I have problem apply the right layer for make, for example, a wall behind or in front of the Player depending on the Player position. I'm able of getting works in ...
0
votes
2answers
9k views

Can't play animation from script in unity

I'm making a 2D sidescrolling game in Unity, and when the player shoots an obstacle, I want the obstacle animation to play and then destroy itself. I got it to destroy itself, but the animation won't ...
1
vote
0answers
21 views

How to draw SharpDX 2D Bitmap Outline

i want drawing bitmap outline Now Drawing Device.DrawBitmap(mBitmap, GetBound(), Opacity, d2.BitmapInterpolationMode.Linear); // mBitmap as SharpDX.Direct2D1.Bitmap // GetBound() as Bitmap Bound ...
-1
votes
0answers
20 views

Zoom only the particular object in unity

I am working on a sample to zoom the particular object when clicked on it.I have used the following code var zoom : int =15; var defaultFov : int=60; var smoothness : int=5; var isZoomed : ...
4
votes
3answers
142 views

Darkness Emitting Light Source Unity

I was wondering if it was possible to create a light source in Unity, one that "sucks" light from the environment. Negative value does not seem to work in Unity, as pointed out by many. It is quite ...
0
votes
0answers
16 views

How can I make an expandable menu and assign names to buttons randomly from an external file using Unity?

I'd like to create a menu on the lower left side of the screen which will present some options (guns) to the player. The number of options should change based on how well a player is doing. In other ...
1
vote
1answer
28 views

What is the maximum value of a LayerMask in Unity?

What is the maximum value of a LayerMask in Unity (the value when all layers are included)? And how can I find it using C# bitwise operations? I tried ~0 but it shows -1 in intellisense. Thanks in ...
1
vote
0answers
33 views

How can I change the list of enum options displayed in the inspector?

I have an array of enums: using UnityEngine; public class EnumsInInspector : MonoBehaviour { [SerializeField] public EnumType[] myEnums = new EnumType[3]; public enum EnumType { ...
0
votes
1answer
149 views

Continuous Jumping Cycle

The script makes a GameObject jump using realistic gravity and reach a specific target. The GameObject jumps relative to the target, thus adjusting its trajectory. It also works while the target point ...
0
votes
2answers
4k views

Play animation when click on each player with in maincamera unity3d

I have 3 gameobjects (player1, player2, player3). I attached a script "playerscript" to these game objects. In the main camera, I have added another script called "testscript". Clicking on a player ...
0
votes
1answer
357 views

Unity5 TextAsset not functioning in WebPlayer

Preface I am working on a 2D Platformer in Unity5 utilizing TileMap techniques. I have a working system to read "Room Tile Data" from JSON files with the Unity TextAsset Class and the Newtonsoft ...
0
votes
3answers
104 views

A method to create and assign a name to a GameObject (Unity)

I'm trying to create a function that takes in a name of an object in the editor and assigns this accordingly as well as the name of a sprite, rigidbody, etc. Basically what I have so far is- ...
10
votes
2answers
5k views

Microsoft XNA Platformer Example, is the Collsion Detection implemented accurately?

The example provided by Microsoft seems as if the collision detection (from what I can see) will have a small error. When the user collides with an Unpassable tile, the depth of the intersection is ...