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
3answers
35 views

Why does a UI button that is child to a canvas not appear in game view?

I am trying to place a button onto a canvas background using C# script. I want the button specific to the canvas (i.e., if I move the camera to look at another canvas, I do not want the button ...
-1
votes
1answer
33 views

How to make a stab function?

I've looked around everywhere, and I can't find an example script for a stab. What I have so far is a top down 2D scene, with a player at the bottom (static). I would like to have the sword/tongue to ...
0
votes
2answers
22 views

Unity - custom Export and Import FBX Data

I am trying to write custom data inside a FBX file from 3dsmax at export time. This might be possible even if I don't know right now how to do that. But my question would be how can I read those ...
0
votes
1answer
39 views

Card/Tile Game, loops dont update element0 of playerHand properly

The Problem I am dealing from another class and into a player's Tray(A class with a List of Tiles and an array of bools to show that a slot in the tray is full). When dealing into the player's tray, ...
0
votes
1answer
140 views

How to properly give Image source for multiple sources?

I'm writing a script to change the image on the button based on previous selection. Another script is giving the CurrentAvatar variable once previous button is pressed. My problem is i can't seem to ...
-1
votes
0answers
29 views

How to rotate an object on a rectangular circle shaped track in unity5?

Actually I have 10 objects and these all are automatically run on playing game as its a betting game which is going to play on browser but I don't know that how to rotate that objects on curve on a ...
1
vote
4answers
96 views

Check if body is on the ground

In my game I have an quite irregular terrain at the bottom and a round ball which can be controlled by the keyboard. Is there any way to check, if the ball is currently on the terrain? This is very ...
0
votes
0answers
18 views

LibNoise Perlin.GetValue not returning noise for zero decimal place numbers

I'm using the LibNoise port from C++ to C# and running into problems generating Perlin noise (Unity demo here). For some odd reason integers never generate any noise. In the code below _firstValue on ...
-4
votes
0answers
27 views

How do I change the control from PC to Mobile? [on hold]

I have my character control script working on the pc. How do I change this script to work for a mobile port? using UnityEngine; using System.Collections; public class Player: MonoBehaviour { ...
0
votes
1answer
40 views

Getting path of right click in unity 3D editor

I want to create an extension for the Unity 3D Editor and have an custom asset type. During the process of creation this I recognized that I would improve the UX/usability if I can specify the path ...
3
votes
1answer
1k views

Calling an android method from Unity3D with a JAR plugin

I am developing a game with Unity only for Android platform and I am requiring to share content of my game through an intent so I have implemented a JAR plugin according to several tutorials with this ...
2
votes
1answer
218 views

Unity - How to save variables for Android Game?

This is my current code, it only work into unity, when i test it in an Android Device it don't save the variable public class Click : MonoBehaviour{ public UnityEngine.UI.Text proiettiliTotali; ...
4
votes
2answers
2k views

Bitmap font rendering, UV generation and vertex placement [closed]

I am generating a bitmap, however, I am not sure on how to render the UV's and placement. I had a thread like this once before, but it was too loosely worded as to what I was looking to do. What I am ...
0
votes
1answer
396 views

Display crosshair that is diplaying where the ship is aiming at

I am creating a 3D asteroids game. I got the bullets, asteroids, and ship all done. They work perfectly. Now I want a crosshair to display where the ship is pointing at. The crosshair will be a 2D ...
1
vote
1answer
169 views

Keeping the meshes “thickness” the same when scaling an object

I've been bashing my head for the past couple of weeks trying to find a way to help me accomplish, on first look very easy task. So, I got this one object currently made out of 5 cuboids (2 sides, 1 ...
0
votes
1answer
62 views

Gravity not being applied to character, using character controller

So I just copy and pasted the unity example class to use with my character controller. public float speed = 6.0F; public float jumpSpeed = 8.0F; public float gravity = 20.0F; private Vector3 ...
0
votes
1answer
47 views

Can't set up a PS3 controller in Unity

So I connected a ps3 controller to my computer via USB cable, when I press play I am able to move by using arrows on the left of the ps3 controller and also I am able to shoot and aim by triangle and ...
1
vote
1answer
61 views

Black Rectangle instead of texture

I am trying to draw a textured ractangle like in this example. But instead of a texture the rectangle is just black. Draw method: protected override void Draw(GameTime gameTime) { ...
0
votes
1answer
29 views

How to create axes for a console controller

What should I change in the input manager to enable me to use a joystick? I have a usb cable to connect the joystick to the computer but how do I set up the controls?
1
vote
1answer
65 views

How to detect collision position and that position's texture color in Unity?

I have a prefab and I use Circlecollider2D for physics operations. I want to detect the color of the contact position of the collided objects ? Is is possible by using Unity's collider classes ?
1
vote
1answer
94 views

What can I do in Unity3D to optimize the way I'm calculating contrast of a texture2D?

I have this contrast script right now in Unity: public void ApplyContrast(string contrast) { try { double contrastD = Convert.ToDouble(contrast); //Make ...
2
votes
2answers
314 views

Camera movement and threshold not working

I have a platformer that is in progress, part of this has a camera which I only want to move when the character moves out of a certain threshold, to try to accomplish this I have the following if ...
0
votes
0answers
15 views

How do I save and perform the commands at client side in unity5? [on hold]

I have been scripting for a web player game for that server sends few commands to client machine But I don't know how to save and perform the operations as per the commands. If anyone knows please ...
2
votes
1answer
159 views

How can I use a lookup table for brightness and contrast?

Currently, I implemented a rudimentary brightness and contrast algorithm that changes brightness and contrast pixel by pixel. This was super inefficient performance wise and the algorithm looked a bit ...
0
votes
1answer
73 views

Monogame / XNA - Multple 2D Cameras (Rectangle) on screen

I recently started building a simple 2D roguelike game using Monogame 3.4. I was keen on building the game "engine" myself as I saw it as a fun learning curve. Monogame was pretty much the best option ...
1
vote
1answer
51 views

How can I accurately simulate orbits in Unity?

I would like to create a space simulation with realistic gravity. This means planets in 3d space which act as central gravity sources and multiple objects which are attracted by those planets gravity ...
0
votes
1answer
40 views

How to correctly draw a 2D polygon in Unity

I'm trying to draw a 2D polygon using GL.Line; however I'm not getting a polygon but separated lines instead. In the example below, I would expect a rectangle formed by the spheres: My code is the ...
2
votes
1answer
66 views

How can I get complete path of a sprite?

I want to get a path of sprite using the spriteRenderer component in Unity.I want my path should be like - "asset/PATH OF MY FILE/FILENAME.EXTENSION". Currently I am using following code but it ...
1
vote
1answer
88 views

Real-time movement client to server to client(s)

So the way that I tried to create a MMO like server communication was by sending strings to every-player containing information and making the client split the string. Example "John" , 42, 64 : ...
0
votes
0answers
16 views

How do I handle or manage commands which are sent by server in unity?

In my game there are 10 objects which are just started running on play as this is a web player game and betting as well and it requires some socket programming. At run time the commands are sent by ...
1
vote
0answers
20 views

SoundEffect.Play and SoundEffectInstance.Play do not work

I am having issues playing a music file in MonoGame. The problem is, an old version worked fine, but I lost it to corruption. Basically, I create an instance, call instance.Play, and hear nothing. I ...
0
votes
2answers
85 views

Implementing a delay timer into triggered method

I have a shoot method that is used as a mouseDown() Trigger on my player. I am wanting to introduce a delayTimer but am unsure of how to do this within the method due to the trigger. public void ...
1
vote
1answer
35 views

My intersect detector isn't working

I'm trying to create rooms dinamically by creating them in random places and checking if they do overlap each other. The idea is that if the new room intersects with another one, it must be recreated ...
0
votes
0answers
10 views

Monogame and winforms - drag and drop images

So I managed to create the form design of my level editor and I embedded Monogame in it using the GraphicsDevice sample. Then I used the PrimitiveBatch sample to draw a black grid 32x32 pixels. Here's ...
0
votes
2answers
137 views

XNA My Texture's Transparency is shown Black

I am trying to draw an image on to the screen. My image is drawn correctly but the background color which is transparent is shown black. Why is this so? My code: spriteBatch.Draw(Texture, Position + ...
1
vote
1answer
37 views

Using coroutines to instantiate larger GameObjects in Unity/C#

We are making a scroller type game for mobile platforms and we got pretty far (Beta is already out). Now we are adding some additional content and are starting to experience a noticable lag when ...
0
votes
2answers
132 views

Help on transition from one position to another

I'm pretty sure I'm over thinking stuff, but I can't seem to figure this out. I want to move the object from one location to another. Here's what I got. I searched this up earlier here, and I found ...
0
votes
1answer
176 views

Unity3d - c# - changing FPSInputController controls through script

For a game I am making I would like the user to be able to change the controls (in game NOT through the clunky launch window (wich i disabled)) I have the system working but don't know how to change ...
4
votes
1answer
3k views

How to correctly draw a line in Unity

I'm working on a game which requires me to draw a few lines from a single point that is more formally said Given point A with coordinates x,y I draw n lines where the i-th line has the coordinates ...
5
votes
4answers
1k views

Drawing 2D Images “3D-Like”

So, I want to use textures for weapons in my FPS game instead of actual models. However, if I just draw the texture onto a square in the game, it has the rotation and stuff, but it looks "2D". How ...
2
votes
3answers
312 views

Scaling 3D furniture while keeping the thickness constant

I am creating a program in WindowsForms and Xna that allows users to create a 3D room. By dragging and customizing different .fbx models, they can "build" a room or whatever and then look at it in 3D. ...
6
votes
2answers
976 views

Arrays for a heightmap tile-based map

I'm making a game using in C# and Javascript that uses a map which has tiles, corners and borders. Here's a graphical representation: I've managed to store tiles and corners in memory but I'm ...
4
votes
2answers
459 views

Jittery Movement, Uncontrollably Rotating + Front of Sprite?

So I've been looking around to try and figure out how I make my sprite face my mouse. So far the sprite moves to where my mouse is by some vector math. Now I'd like it to rotate and face the mouse as ...
0
votes
0answers
14 views

Need help with torque and velocity [closed]

I made some basic movement code for my player in C#. Here it is: public class Movement : MonoBehaviour { public float rotationspeed = 100.0f; public float maxrot; void Update () { ...
0
votes
1answer
59 views

Rotation and timer at the same time

I have a project where I flip a card after 5 seconds, then I want to start a countdown timer of x seconds. After x seconds the card flips again. I found a good example for the timer here, but that ...
0
votes
0answers
13 views

Web Player build is not playing on web. Why? [closed]

I have been developing a web player game and after completing the build process in build settings I clicked on that build file then I found that the build was not playing on web and was showing some ...
1
vote
1answer
153 views

Problems with Raycasting Requirements

Im working on a script which kinda works like an Enemy AI. Its kinda like a detection system with requirements that are required to be met. This is a recent question i asked using my code Raycast ...
0
votes
2answers
38 views

Why does my MonoGame mesh throw an unhandled exception when trying to draw?

I am using the '3D Models' chapter of Learning XNA 4.0 to further understand 3D implementation in XNA, but I am running into an unhandled exception, when I try to draw each mesh. Here is my basic ...
6
votes
2answers
563 views

A* pathfinding for dynamic obstacles and player made blockages?

Hi I'm creating a TD in Unity 5 and need some help with my Pathfinding. I'm going to use Arons A* pathfinding for my AI which enables me to use dynamic objects and update the path during run-time. ...
-5
votes
1answer
36 views

How can I properly implement Lerp in this code so that the it can run smoothly in every device? [closed]

How can I properly implement Lerp in this code? if (isJumping) { actualSpeed -= slowAmount * Time.deltaTime; transform.position += Vector3.Lerp (0.3f, actualSpeed * Time.deltaTime, 0); ...