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

1
vote
1answer
287 views

Unity Texture2D raw data TextureFormat problem

I am trying to load raw image data into a Texture2D in Unity using LoadRawTextureData but I can't get it to work correctly. First I receive an array of bytes from an unmanaged function that captures ...
0
votes
1answer
22 views

Change material emission for a second then go back to default

I'm looking for a way to change the emission of a material for a second then get it back to where is was by default Here's what I have for now float emission_lvl = 5.0F; float emission_lvl_start = ...
0
votes
0answers
44 views

2d Lighting over Sprites in C#

I am currently working under a project , a small application where i have to implement 2d lighting . For example , in the GDI+ canvas , a image will be drawn and i will have to put a lighting effect ...
0
votes
0answers
24 views

Only Instantiate once? [on hold]

How do Instantiate only once? This script continuously create clones. GameObject[] cubeParticules; foreach(GameObject part in cubeParticules) { Instantiate(part, temp1, ...
2
votes
1answer
357 views

NegaScout with Zobrist Transposition Tables in Chess

I'm trying to put Transposition tables into my alpha beta scout. I do see an incremental speed boost I think toward mid or late game, however, even with a table size of 1-2GB, its may or may not be ...
0
votes
1answer
28 views

MonoGame-based animation system fails to change animation [on hold]

We have a problem with the animation. The problem is that it won't play the right animation. We are using a spritesheet with 4 frames: idle, movement and so on. Here's the code we are using: class ...
0
votes
1answer
504 views

When should I set a texture as a shader resource in order to read it?

I'm writing a Direct3D 11 HLSL shader with SharpDX. What I want to do is write the depth to a texture in one pass and read it in the next one. After declaring the texture, do I have to set the depth ...
2
votes
0answers
69 views

Tower Defence stat storing system

I'm trying to find a smart way to store and retrieve stats for a tower defence game, but am currently unsure as to which approach would be best. Description: The stats system should quite basic, ...
0
votes
2answers
57 views

Get Particular Object's collision status via C# script

My current scripts creates and modifys the location of various prefab objects as they go along the screen. One of the things I want to find out about the active object is whether it has collided with ...
3
votes
1answer
54 views

Lidgren not starting server properly

I have a server set up for my game with Lidgren, and it works well when I have it set up on one machine, but if I try to run the server on another machine, I am unable to connect from other machines. ...
0
votes
1answer
52 views

Distance based item interaction

I'm having an odd issue in my implementation of distance based object interaction in Unity. Basically it's a simple "Press [key] to [search/pickup/open/etc]" function which requires the player to be ...
6
votes
2answers
3k views

How to make Line Renderer lines stay flat?

I've noticed that as I add more vertexes to a Line Renderer line the line twists and stops being a smooth line. .GIF Here: http://i.imgur.com/hRAhCXM.gif All lines are on the same z level, even ...
1
vote
3answers
98 views

Game Object is Instantiating on same position

I am working on a small project . But now I have come across a problem . The problem is the prefab is instantiating on the same position . I want to instantiate a box end to end . The basic set up is ...
0
votes
1answer
42 views

How would I handle collision to all instances of one object? (C# and monogame)

What I'm saying is, let's say I have a list. That list contains all the tiles in the game. I use this to update them all, draw them all, etc. for (var i = 0; i < Tiles.Count; i++) { ...
0
votes
1answer
49 views

Set input relative to map rotation?

I'm trying to figure out how I can make the input which looks like this : // Checks if player is pressing movement keys, if is applies force to specified direction if ...
1
vote
1answer
77 views

In Unity, how can I modify the shape of a sprite?

I am new to Unity and programming in general, however, I wanted to know how to change a sprite's shape. I want to do this while the game is running, so I was thinking about removing a set of pixels ...
6
votes
4answers
129 views

How to properly differentiate single-clicks and double-click in Unity3D using C#?

What I am trying to understand and learn here is a very basic thing: what is the most general and most polished way to properly differentiate single-clicks and double-clicks for the 3 main mouse ...
0
votes
1answer
286 views

Getting Image name given a canvas WPF

I have a bunch of images I'm using for a chess game in a canvas using wpf, xaml, and C#. I want to use Canvas.SetTop(image, position); to set the position of this image. However I am given the ...
3
votes
1answer
53 views

I want to render a texture2d on to the screen in unity, how do I do this?

So I have modified a texture in C# by removing all of its white pixels, now I want to render it on the screen in unity so that later I can use it as a terrain where I can make my sprite walk. So far, ...
2
votes
1answer
41 views

Find your value between four values in a grid based on distance, Unity

Please note: Originally posted in stack overflow, redirected due to nature of problem. I am making a procedural mesh game. I am trying to calculate the temperature for the player's current chunk by ...
0
votes
1answer
23 views

Can 2D Rigidbodies detect collisions with 3D Box colliders?

I would like to know if Rigidbody2D's can detect collisions with 3D Box colliders and/or normal rigidbodies. I seem to have a problem where my 2D Colliders don't detect collision with my 3D Cubes. ...
3
votes
4answers
246 views

Get OnMouseDown to work with a 2D Polygon Collider

I'm having a hell of time getting a 2D polygon collider to register a mouse click. I've attached images and code to show where I'm at. I cannot get the click to work. Ultimately, the thing I'm trying ...
-1
votes
2answers
27 views

Using VBO in Opengl. powered with c# TAOFramwork

I'm doing a 3D display for a big object. I've managed to display it with opengl primitives, so it's (very) slow Now i want to use the VBO optimization. But when i lost the focus on the opengl window ...
2
votes
2answers
710 views

Control animation using animator control class

I did a sample existing code to control animation using animation.I dragged and dropped a character into the scene then I added a Animator to it and added the animator controller.Below I have given ...
0
votes
3answers
292 views

Unity Application.LoadLevel freezes the game on Android device

I'm developing a game using Unity. The game has a single level and after the player wins/loses, I simply want to reload the same scene. Here's the code I'm using: private void OnLevelFailed() { ...
1
vote
1answer
44 views

2d Player animation issue in UNITY 3D

I have a player and i want to move the player from left to right. I can move the player by the keyboard events.but the problem is that when i release the key the player animation should be idle. ...
0
votes
0answers
32 views

How to navigate through google Map in unity [on hold]

I am working on loading the google map and navigating through the map. I have loaded the google map which shows the current location in unity. Now I need to show the direction from Place A to Place ...
4
votes
2answers
275 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 ...
1
vote
1answer
62 views

Animation Scaling?

I have an animation that changes the scale of the GameObject but also happens to change the position as well. I do not want the position to be changed by the animation, only the scale. How can I do ...
0
votes
1answer
99 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 ...
-1
votes
1answer
59 views

Bullet only removing closest enemy

I'm having an issue with my collision detection code. I'm making a top down shooter and when I shoot, the bullet will only destroy an enemy if it's the closest enemy. The bullet will go right through ...
0
votes
1answer
58 views

My character gets stuck when It's running on a straight level ground

My project is an infinite runner that goes right in a straight line. Sometimes when it just runs without jumping the Player stops. Sometimes the Player doesn't stop. When you jump the Player usually ...
0
votes
2answers
248 views

animation control problem

I have a list of .FBX object.When I drag that .FBX into scene its corresponding inspector Animation component(fig 1) appears but when I drag some other .FBX object into the scene the Animator ...
0
votes
0answers
17 views

unity component architecture [on hold]

Would it be sensible to split components into domains, then further by behaviour, and have behaviour component scripts act as an interface between OOP code and the Unity engine? domain > components ...
0
votes
1answer
48 views

Enemy Retargeting

i am trying to make a game using navmesh agent in unity,where the enemies first attack the player and change their target to tanks when player spawns them.then again retarget player after the tank ...
-1
votes
1answer
65 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
33 views

Creating Slide-In Text [duplicate]

I want to make my text slide like so: This is from the game "Crossy Road". The movement is normally smoother that in the .GIF Here are some more frames from the GIF to make you understand what I ...
4
votes
5answers
747 views

In Unity, how do I correctly implement the singleton pattern?

I have seen several videos and tutorials for creating singleton objects in Unity, mainly for a GameManager, that appear to use different approaches to instantiating and validating a singleton. Is ...
0
votes
0answers
32 views

Help creating an animation in Unity? [on hold]

How can I create an animation that looks exactly like the one below (the moving hand pointer)? I have no idea on how to start. Thank you for your help.
-1
votes
2answers
4k views

Unity 5: Error when everything is okay(Object reference not set to an instance of an object)

i'm getting this error when the collider colides with something: Object reference not set to an instance of an object It's referencing to the gamecont.Death(); from this script: and the death ...
1
vote
1answer
181 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 ...
0
votes
1answer
58 views

Problem in Unity ad

I am trying to place ad in my game. i am using unity 5. trying to place admob in my game. in unity editor it displaying dummy message. tried to build the game in android phone after build completed ...
0
votes
1answer
186 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 ...
0
votes
2answers
112 views

Bullets doesn't do any damage

I have a melee enemy tagged as enemy. enemy has two coliders: a capsule(physics) and a sphere(for attacking player in radius and istrigger) and a particlesystem, enemy has enemyhealth script attached. ...
1
vote
2answers
7k views

Changing color of UI Text in Unity into custom values

There are a few objects in the scene as well as a title. I want the title to change its text and color based on the object that is mouse-overed. The script below is added to each object that is ...
1
vote
2answers
2k 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
1answer
49 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
463 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 ...
0
votes
2answers
766 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
312 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 ...