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
2answers
67 views

Using my pathfinding more efficiently

I'm making a roguelike in C# with the Roguesharp libraries, in which the map can be as large as 200x200 cells. When I have an entity requiring pathfinding, I am using Roguesharp's built in pathfinding ...
1
vote
1answer
72 views

How can library classes access SpriteBatch?

I have a spritebatch in my primary game component in a game project: public class GameRoot : Game { private SpriteBatch mySriteBatch; public SpriteBatch MySpriteBatch { get { return ...
1
vote
0answers
125 views

In game replay system doesn't work correctly when animations are used on a character

I have created an in game replay system that essentially just stores each object's position and rotation at each FixedUpdate(). Once an even is triggered, the replay is then played back using ...
3
votes
1answer
376 views

Generating mesh along path

I'm currently trying to generate a path along an array of points(Vector3) This is the result i'm currently getting The dark gray points are the given path The red points are the generated verticies ...
3
votes
2answers
159 views

Traffic system in isometric game

I would like to create a traffic system in my tile-based isometric game and I would like to ask for some good approaches because I don't have a clue how to begin. Right now I have a tilemap and keep ...
1
vote
0answers
32 views

Export UnityProject inside Android Studio's existing project

I am new to the Unity3D, but I have made a small Unity project with a humanoid gameobject. I can move this humanoid with the demo data but I want to move it with the quaternion data which I am already ...
1
vote
1answer
28 views

How to Ignore Raycast for Boxcollider2D by layer or boolean?

how can I ignore Raycasting for specific object,perhaps you say use Queries Hit Trigger but when I use it Ignore all Raycasting for triggers but I want filter Ignore Raycasting for some objects I need ...
1
vote
0answers
52 views

Unity game randomly closes when phone is streaming the screen?

My Unity android game (frequently) randomly closes on some phones when it's streaming with the YouTube Gaming App for example. I have Unity version 5.3.5f1. I have to say that this phenomenon did not ...
3
votes
1answer
144 views

Trying to implement forward rendering in OpenGL

I'm working on implementing forward rendering in my 2D engine, as far as I'm aware everything should be set up correctly, I've ran into some issues earlier but I'm sure I've fixed those at this point. ...
1
vote
1answer
85 views

Problem disposing content from a screen's content manager

I have a problem with my game. I am using multiple classes for different screens, for exemple: Main Menu is one screen, When playing is another, and so on... I decided to use multiple ...
1
vote
4answers
364 views

Move ball based on direction of force?

I'm trying to make a ball that will move in the direction I push it from, and later pull it to me based on where the player is standing. using UnityEngine; using System.Collections; public class ...
-1
votes
2answers
109 views

how to create a play button and load game on play? Monogame

I need help with understanding how I can make my function work and load the game when pressing play. At the moment, when I press Play, it won't update or missing update o knowing the button is ...
2
votes
2answers
68 views

object smooth orbital limit around another object depending on mouse drag

I am working in Unity. I have special objects that can each be dragged freely around in 2d. The objects cannot get too close to other objects (minimal Vector3.distance allowed is 1.5f). I also have ...
0
votes
1answer
98 views

How to handle collision detection

So the way that I am doing the movement for my game is that you can left click a unit (which is just a rectangle object), and then it is selected. While it is selected, you can right click and that ...
1
vote
1answer
124 views

Unity Collision Doesn't Work when Two Players Instantiated

I am using Unity3D and I have a problem. I have a script which instantiates the player gameobject once you are connected to the server. I also have an attack script. When there is only 1 player on, ...
1
vote
1answer
175 views

How do I render my DirectX C++ engine to a C# Panel?

The title pretty much sums it up. I'd like to know how I can get the HWND of my C# Panel object to my DirectX engine so I can render to it. I know it involves making a C++/CLI wrapper, but I'm not ...
-3
votes
2answers
70 views

How do I write to a text file in Update function of a script? [Unity|C#]

I have a Unity C# Script which updates a variable each time the Update function is called. I would like to know how to write to a file from the update function.
-5
votes
2answers
72 views

How can I test which of two gameobjects is closest to a third gameobject?

It would be nice if it was as simple as: public void Closest() { if (A.distance > B.distance) {} } But any sort of workaround would be acceptable.
0
votes
1answer
100 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. ...
2
votes
1answer
287 views

Modularization in a project

I'm writing a C# game in Mono, and I want the game to be as modular as possible. I've started by writing the whole Item (inventory) System of the game in a seperate .dll library But I've hit a problem....
0
votes
1answer
40 views

Creating 3D gravity in zero-G tied to mass in unity with c#

As a total beginner, I've been working on a patch-job script for a gravity mechanic in an open space sim, I want to derive all my objects from this "Block ALPHA" object and its' set of variable ...
0
votes
2answers
68 views

How do I reference one gameObject with script attached to other?

this is all in Unity 3D with C#. Thing is, I have attached a script to my player that should Destroy TreeGroup (as in forest) whenever I press 'Q' and Instantiate them when I press 'E'. Here is the ...
0
votes
1answer
32 views

Coroutine wrong Behavior when scene is loaded.

Ok so I have this coroutine : IEnumerator ShowCharTraits() { while(!hasPlayerChosen) { yield return null; traitPanel.SetActive(true); } ...
0
votes
1answer
94 views

Unity AddExplosionForce to a Navmeshagent

the navmesh agent is intaracting with the exploding object, explosion occurs and agent takes damage but no pushback occurs. expodingobject using UnityEngine; using System.Collections; public ...
1
vote
1answer
45 views

How do I toggle color writes in SlimDX 11/Direct3D 11 with FeatureLevel 10?

I'm having trouble setting the RenderTargetWriteMask field of a RenderTargetDescription struct. I simply want to toggle color writes but every time I try to enable the the color writes are changed ...
1
vote
0answers
21 views

Weapon Sway Script messes up weapon rotation

So I'm in the process of learning Unity 5 and scripting in it. One thing I wanted to give a try was to make a simple weapon sway script like you see in games such as battlefield or csgo. After a bit ...
0
votes
1answer
506 views

3d Wall sliding collision

I'm working on collision for walls in my game and the way I currently have it I get stuck walking into a wall. I'm trying to make my character slide on the walls but still collide. My character moves ...
1
vote
1answer
47 views

How to switch between sprites in Unity

So I made an empty game object in inspector, called it "squareTest", and I clicked and dragged 3 sprites in. One is the square being black, one is the square being red, and one is the square being ...
1
vote
1answer
44 views

How to use NoSQL REST API of Gamesparks in my Unity project? [closed]

Gamesparks has a documentation of the API but I am not sure how to send https requests to use that API.
2
votes
1answer
539 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
370 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 ...
1
vote
3answers
96 views

Unity AddForce causing twitch

Since this wasn't clear enough, I've removed even more code. It kind of defeats the purpose I was aiming for, but I guess getting any answer relevant to the problem is better than none. What I want: ...
0
votes
1answer
40 views

Elastically Object movement in unity3d

I want to move an object towards the destination elastically. Currently I am using Vector3.Lerp it working to move the object, start with high speed and reached at destination with low speed but ...
1
vote
0answers
26 views

Unity - SerializedObject.ApplyModifiedProperties() using relavant property setting method

The problem I have is this. I have an editor script, at the end of OnInspectorGUI() I want to apply all the changes with the serialized object. The simplest way to show my problem is thus: [...
0
votes
1answer
333 views

GUI.DrawTexture problem in Unity

I'm having a problem with GUI.DrawTexture() and I'm looking an alternative function to draw 2D Texture Images. The problem I have is that my textures draw above all other objects and when my camera ...
0
votes
3answers
68 views

How do I make my Unity application quit programmatically?

I made a script and I want to make my game quit, but this does not work. How should I go to make the app quit? using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; public ...
2
votes
1answer
214 views

2D lighting causes black rings to appear

A year ago I implemented 2d lighting in XNA using sprites. The sprites I used were created by placing a soft white photoshop brush on a transparant background. The result was this: (lights only) ...
-2
votes
4answers
98 views

How can I exclude a range of values when generating random numbers?

If you are using Random.range to generate values, is there any way to exclude some values within the range (for example: pick a number between 1 and 20, but not 6 through 8)?
0
votes
0answers
23 views

Lense distortion correction with unity5

I am working on lens distortion correction in Unity. I created a new scene dragged the "Cardboard" prefab to the scene. In the cardboard setting I have set the Distortion correction as "Non". and I ...
3
votes
2answers
260 views

Mock Collision Object in Unity

Problem: I'm trying to set up some tests with mock collision objects, but i cannot construct collisions with custom objects. What I'm trying to do: Collision2D col = new Collision2D(); col....
0
votes
1answer
60 views

Trouble GamePad input on iOS but works perfect on Android

I am having trouble getting input from on iOS devices (iPhone 6 Plus and iPad). Here is my code, if (Input.GetKey (KeyCode.JoystickButton14))// A { chr_show = "A"; } if (Input....
0
votes
1answer
37 views

Move unit 64 pixels at a time Unity3d

I'm new to Unity and am trying to learn how to use it. I'm making a 2D top down Frogger-esque game. I was wondering how you would go about making the player move x pixels per button press. I currently ...
1
vote
2answers
23 views

Modify the Y position of a GameObject on startup

I'm trying to modify the Y position of a GameObject on startup with the script below: int y; void Awake() { y = Random.Range (140, 155); Vector3 temp1 = transform.position; ...
2
votes
2answers
745 views

Unity 2D Alpha cutout layer for Sprites

I'm trying to make a simple Fog of War effect for my 2d game, similar to these: . I want to have a sprite layer of black and then have a sprite to cut out itself from the black layer, leaving a ...
0
votes
1answer
13 views

Playing an animation all the way through with one quick keypress with Mechanim Unity

I have an if statement inside of the Update function that is only called if three other conditions are met. The problem is that right now the function sets a boolean to true which causes the animation ...
0
votes
1answer
66 views

C# OpenTK Text rendering

I've been looking everywhere for a solution on how to render/draw text for my 2D OpenTK-based game. Been trying quite a few QuickFont ones without success (either a AccessViolation exception or text ...
1
vote
1answer
442 views

XNA (BEPU) Physics Performance

Im using XNA 4.0 with the BEPU physics engine v1.2 and I have encountered some performance problems on Xbox. Im not sure if the my mesurements are an expected result of the Xbox (with alot of dynamic ...
0
votes
0answers
50 views

C# Moving object from point to point and back

I was trying to make an algorithm that makes an object move from a point to another point and back (in C#), but I can't make it work. Does anyone know a correct way of doing it? The code I used is ...
0
votes
2answers
52 views

MonoGame Gamepad Y axis flipped?

I'm following a book I bought on Google Play that is teaching me the ropes of MonoGame, and in Chapter 2 it introduces creating an input wrapper that takes care of all the input methods for a game pad ...
2
votes
2answers
19k views

How to add a UI Text for keeping Score in Unity 5

My Problem is simple I want to show scores on my game. The examples on internet are good but in Unity 5 there are no GUI elements but instead these are now UI elements. I was following this example: ...