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
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: ...
3
votes
1answer
1k views

How do i define array in shader's constant buffer with C#?

I am using SharpDX to render 3D graphics and i cannot get to work constant buffer in my shader since it contains an array. Currently it looks like this: cbuffer cb0 : register(b0) { matrix mWorld;...
0
votes
1answer
114 views

Slow collision detection at low frame rates

I'm experiencing an odd issue with my collision detection. I'm using the Update method to move the player (I don't want to use FixedUpdate because that creates an undesired weird movement). The fixed ...
31
votes
5answers
6k views

Use an instance or a class for game resources (wood,iron,gold)

So I'm making a game where you can send ships to locations to sell or buy resources like wood, iron, gold, etc. Now I was wondering how the resources should be created in de game. I came up with 2 ...
0
votes
1answer
119 views

Creating a Board Game Strictly Using Windows Forms

I'm working on my final project for a Software Design class, and we've been tasked with creating a board game, specifically Risk. Right now, the back-end game logic is functional, however I'm ...
0
votes
3answers
308 views

Arrow key control on winforms RichTextBox

I am making a faux console using winforms for the game I am working on. Right now I am moving a '0' across the screen using the arrow keys. In order to provide fine grain formatting on the text, I ...
0
votes
1answer
105 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 ...
1
vote
1answer
146 views

Keeping object a fixed distance from the ground, buggy behavior

I'm trying to make a script that will keep my object exactly 1 meter from the ground. So far I've got the following code : using UnityEngine; using System.Collections; public class ...
0
votes
2answers
47 views

snap an object to another object?

so I have some walls which are cubes stretched along a direction.and I have some windows and doors that are suppose to snap to a wall and don't let go until the desired location is out of the snapping ...
1
vote
3answers
440 views

UNITY : I want to make my UI text fade in after 5 seconds

I know this question has been asked and asked but none of the topics i visited gave me an answer. I'm making a game programmed in c# where you control a boat and i want my UI to appear smoothly by ...
3
votes
2answers
103 views

Start Menu Does not Work

On starting the game, a basic startmenu should load. startScreenUI is the background image, and startUI is the buttons for "play" and "exit". I set Time.timescale to zero in Awake() so that the time ...
0
votes
1answer
76 views

Rotation Continuity help

First the issue im having: Basically its the fact that the angles of a circle aren't continuous, they rise from 0 to 2pi then immediately fall back to 0. I want to make a game where the player ...
0
votes
1answer
28 views

Unity 2d square position not lining up with its size

I want to have one square that rests at the Unity 2d coordinates (5,5). Using transform.localScale I make the square be 3 units by 3 units large. So I thought that if I made another square that is the ...
0
votes
1answer
73 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 ...
0
votes
0answers
12 views

How to write array of rgba to RenderTarget as a bitmap?

I have data in rgba format that I want to display as an image in my OnRender() method. I would like to do something similar to this: // initial data int [][] rgba; ...
2
votes
3answers
488 views

2D Game has very bad lag because of one script?

I am making somewhat of a flappy bird clone (mostly for practice) and everything works fine, but it is just really slow with a low FPS of 13 and a max FPS of 28. Why would this be? So I ran a check ...
0
votes
2answers
218 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
1answer
68 views

Detect collision with static collider only

Is this possible to detect collision with static colliders only I check it is not working. I dont want to use rigidbody or character controller with my box collider.
0
votes
1answer
73 views

How can I access the translation part of a skinned Model object's bone transformation?

I have an animated Model, which I process with the SkinnedEffectProcessor. How I can access translations of that model during animation? It's always a BoneTransform I am working with, but I'd like to ...
1
vote
1answer
37 views

Physics2D raycasting with a perspective camera and tilted sprites

So i ran into this problem today. I want to have a perspective camera and sprites that are rotated by lets say 1.5 on the X axis. The problem is that the 2D raycast does not work correctly, it returns ...
2
votes
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 ...
1
vote
1answer
59 views

Unity question: When attaching my custom camera script camera shakes when player starts to move fast [duplicate]

Here is my player code. Rigidbody rb; Vector3 currMovement; public float jumpSpeed = 10; public float moveSpeed = 10; public float rotSpeed = 180; float distToGround; public float smoothTimePos = ...
1
vote
1answer
229 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
2answers
32 views

Check which object trigger another

Two animated car object both contains rigid-body and box collider and a script with OnTriggerEnter event. Now I want to check that which car hit to another car. Means if A hit to B or b hit to A as ...
0
votes
1answer
63 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 (Input.GetKey(KeyCode....
4
votes
2answers
302 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 ...
3
votes
1answer
80 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. ...
3
votes
4answers
519 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
1answer
47 views

Unity: When attaching my custom camera script camera shakes when player starts to move fast

Here is my player code. Rigidbody rb; Vector3 currMovement; public float jumpSpeed = 10; public float moveSpeed = 10; public float rotSpeed = 180; float distToGround; public float posSmoothTime = ...
1
vote
0answers
26 views

Unity play sound from Audio Source

I'm using the following code to play a sound in Unity 5: AudioSource aud = GetComponent("doorSound") as AudioSource; aud.PlayOneShot(aud.clip, 1.0f); But no sound is playing at all. What am I doing ...
1
vote
1answer
32 views

How to use Resources.Load with an AudioClip in Unity?

I'm trying to load an audio clip that's in my assets directory and play it. Here is my C# script: if (Input.GetKeyDown(KeyCode.X)) { audioSource = gameObject.GetComponent<AudioSource>(); ...
0
votes
1answer
335 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 ...
0
votes
2answers
28 views

Moving towards and switching targets in Unity with collision

I have these nodes set up for a ship to move towards over time with out looking stops then repeats in a sequence. like so: 1 2 3 1 2 3 1 2... THE PROBLEMS i keep having either come from the ...
0
votes
2answers
269 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 ...
2
votes
1answer
79 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 ...
1
vote
1answer
97 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 ...
3
votes
3answers
86 views

Does AddForce continue to add force indefinitely?

Does the AddForce method continue add velocity to an object forever? Does it need to be limited by another line of code? Sorry if it is too broad or too simple; I am completely new to programming and ...
0
votes
1answer
38 views

Unity 2D C# Enemy Attackng Ai issue

Ok to be specific, both of my enemies will continuously play their attack animation even when it is false. I don't understand what I am doing wrong here :( void OnTriggerEnter2D(Collider2D other){ ...
2
votes
1answer
56 views

How do I expose a field of an abstract type to the Inspector?

I have a class hierarchy with an abstract parent class. I would like to have a field of this type exposed to the inspector but it appears to not display. This test code: [Serializable] public ...
4
votes
1answer
238 views

How do I expose a field with a generic class to the Inspector?

I have some utilities implemented as generic classes. I would like to have fields of these types exposed to the inspector but they appear to not display. This test code: [Serializable] public class ...
3
votes
1answer
110 views

Function, that is searching for nearest enemy Transform only works sporadically. What am I doing wrong?

so I am trying to implement a "Zelda"- or "Dark Souls"-like z-targeting system. You'll see in the code, that the function compiles a list of every enemy in the current scene. I'm still in the ...
0
votes
0answers
35 views

List derived class serialization

I have an extremely simple ObservableCollection<T> implementation using [Serializable] public class ObservableCollection<T> : List<T>, INotifyPropertyChanged {...} in Unity3D with ...
1
vote
0answers
65 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
3answers
43 views

Unity inspector script - making it save the global variables for what it's creating

I have a script which initialises a bunch of child gameObject(s). I wanted all of this to happen outside of the game, so I created an inspector script which has a button which triggers the method ...
3
votes
1answer
43 views

How can I add a new item to my enum list in the inspector?

I have a list of enums. I want to add a new item to it without scripting to make them more easily modifiable for game designers. I made an inventory system and I want to define the type of an item. ...
0
votes
1answer
27 views

Can't add inspector variables to script?

So I just added this script to my project : https://www.assetstore.unity3d.com/en/#!/content/11278 Since this script only draws the lines on gizmos, I wanted to add a LineRenderer, so that I can draw ...
0
votes
0answers
10 views

Unity Make a 3d object intersect pass through 2d UI

I'm trying to make a 3d object appear as if its approaching a 2d object. As So: The sprite is 3d and it should pass through the 2d button. Since the hand above can move freely I can't put it on a ...
1
vote
1answer
584 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 ...