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

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 ...
1
vote
0answers
66 views

Polygon 2D collision response- How do I find the correct edge a polygon hit?

Hey guys I've been seriously stressed out by this, so please go easy on me. My goal is to reflect a bullet (polygon) off of another polygon, and find the edge the another polygon, A (the bullet), hit....
2
votes
0answers
29 views

Frame Skips in MonoGame

I'm developing a 2D game using MonoGame. I've got a square on the screen I can move around. The problem is that about once a second, the square jumps a bit. Using a frame counter I found here I've ...
4
votes
3answers
54 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 ...
2
votes
1answer
28 views

Unity API - Making a Sphere Jump?

I'm making a very simple game with a sphere that's supposed to roll and bounce on "planets". Also, please be ready to read a lot. I want to be very descriptive for you. :) I've pretty-much-done ...
1
vote
0answers
23 views

How to Convert DirectX Texture2D to a DXGI Surface for WPF Rendering?

I have an image in my WPF application that uses a D3DImage to render DirectX content. On the DirectX side I render everything to a Texture2D using SharpDX (a C# DirectX wrapper), but I'm not sure how ...
4
votes
1answer
83 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. ...
5
votes
1answer
309 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 ...
0
votes
2answers
1k views

How to make a gameobject Scale up from another GameObject script

I'm trying to make a GameObject grow in scale from touching this one, and when a set amount of scale is reached destroy this GameObject ( the one who scales up the other). My problem so far is that ...
0
votes
2answers
583 views

SceneManager.GetActiveScene(); return -1 when Debugging active scene in editor

I'm trying to use the new SceneManagement since Application.LoadLevel is obscelete and I've read that we need to put it like this. using UnityEngine; using System.Collections; using UnityEngine....
1
vote
0answers
23 views

Third-person Steering with Samsung Gear VR Unity

I am working on third-person steering, where you see the object like car, plane, spaceship in front of you as you steer it. I have got the code for Google Cardboard . How can I implement this in ...
1
vote
1answer
602 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 ...
1
vote
1answer
62 views

Unity 5.3.5 - How to setup a lobby with general game settings?

I am currently working on the lobby for my game. I have followed these tutorials (https://www.youtube.com/watch?v=jklWlm5v21k), which were very helpful, and was able to setup my lobby like this. The ...
1
vote
0answers
13 views

Move around the object using head tracking movement in Unity

I am developing an app for Samsung Gear VR with unity.I have added a cube and made the cube move forward on the terrain. Now I need to move around the cube using head tracking movement.I have ...
0
votes
1answer
188 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 ...
1
vote
0answers
26 views

Monogame intermediateSerializer with winforms

I want my xml files to be game ready on save in my winforms. Right now I am trying to serialize a simple object like this and it is accessing the XML file, but not outputting anything. Am I missing ...
1
vote
1answer
110 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
175 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
vote
1answer
83 views

Unexpected Execution Order in Unity (uNet)

I made a little game in Unity. It works fine in the Editor. But if I run the build version I get a NullReferenceException. This problem does only appear if the build-version-client hosts the game. ...
4
votes
3answers
317 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
1answer
103 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 ...
1
vote
1answer
44 views

Deriving from base class but not calling base method

I am very new to C#, XNA, and OOP. This is my question: I have an abstract class called Sprite. Sprite handles position and drawing from the sprite sheets, from its update and draw methods, for my ...
2
votes
2answers
11k 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
3answers
105 views

Access a Private GameObject in Unity

Hope you bear with me, I'm a beginner! Maybe I should've paid better attention to the tutorials but they all seem to use public variables/game objects that we can then drag into using the Unity Editor....
0
votes
1answer
102 views

Zoom at a specific point using Orthographic camera

Currently I can perform Zoom which seems to be working fine but essentially what I'm really trying to do is zoom on a position offset from center as currently when I zoom then zoom is performed at the ...
4
votes
1answer
167 views

Unity's Animator.GetBehaviour<T> always returning null

I have the following line: As you can see "transitionOutAnimator" is null before the line runs. transitionOutAnimator is a StateMachineBehaviour of type ThoughtBubbleTransitionOutAnimator. We can ...
3
votes
1answer
63 views

How can I create “events” that are called in scripts without requiring subscriptions?

I am creating an editor extension that includes an API for developers to use. It also includes events like (for example) "OnHealthChanged." The problem is that events I have stumbled upon would ...
1
vote
0answers
24 views

Unity 3, TouchScript - Detects touch position each time it changes position

I have a big problem here. I am making a script to detect a circular swipe, so I need to continually detect a touch position that keeps a magnitude and that the angle is relative to the former angle ...
1
vote
1answer
187 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
1answer
84 views

How can I instantiate in the current rotation in Unity 2d?

Backstory I'm currently working on a 2D sidescroller/platform game as a hobby, and I just started recently. Followed a few tutorials and such I managed to wrote my own code for basic command like ...
2
votes
3answers
526 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 / ...
1
vote
2answers
36 views

Implementing an interaction system that can perform different tasks dependant on the object you are trying to interact with?

In No Mans Sky there are objects to interact with in the world and the result of the interaction changes depending on the object. For example, if you interact with a plant it will give you resources ...
0
votes
1answer
94 views

Monogame - custom json content importer

I am trying to build a JSON tile map importer for the content pipeline of Monogame but I'm having difficulty doing so. I have been following this tutorial and got something... But now it appears my ...
0
votes
0answers
23 views

Importing animated Collada from blender to monogame c#

I have some problems with rendering animated Collada files in monogame. I understand animated skeletons, but in Blender is way to animated without making skeletons. Let's say, I want to make a ...
1
vote
1answer
38 views

why the camera won't rotate around my object?

im new to unity scripting, and now am building upon "Roll a Ball" example in unity training. I wanted to make the camera rotate around the ball in the scene in Y axis, when mouse is moved, and watched ...
0
votes
1answer
18 views

Animator consecutive set parameter problem

I'm having a little problem with my animations transitions. I have this diagram: http://imgur.com/Se8Ix1L My transitions is made by updating the parameter "stateparam". My code, changing the ...
4
votes
1answer
132 views

Monogame Startup Memory Spike

I am currently porting a game from WP7 using XNA to WP8.1 using MonoGame. I have been putting considerable effort into optimizing my game to be under the 185MB memory limit for low-memory phones. I ...
2
votes
1answer
133 views

Drawing Farseer Fixtures

Is there any way how to draw a Polygon / Fixture from Farseer Physics with XNA? As I deform these polygons at runtime I can't take any texture from my Content folder, the texture must be generated at ...
1
vote
1answer
99 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 ...
1
vote
1answer
1k views

What is the proper way to get input from the motion controllers touch pads?

I've been trying to figure out how to get the inputs from the touch pads on the motion controllers but have yet to find out how to do so. Initially I tried doing the following (as it was how I ...
0
votes
1answer
22 views

Problem with camera drag and draggable UI elements

I implemented my camera drag using the following method: if (Input.GetMouseButtonDown(0)) { dragging = true; followPlayer = false; oldPos = transform....
0
votes
2answers
34 views

Animation clip not working

I am working on playing different animation of key press.Below are the animation element attached to my player Initially run animation is played.I have written code to play "Jump" animation on ...
0
votes
1answer
100 views

How to keep a rigidbody on the ground going up/down a slope? (Unity 2D)

I'm not sure if this is possible, but Im working a 2D project to has randomly generated loops (imagine a sin or cos graph). I have a 2D character (a quad for now). I want my character want to ski a ...
0
votes
2answers
73 views

Projectile Direction Unity

I want to shoot a projectile in the direction the gun is facing. With my current script it only shoots vertically. (I can also make it go horizontally but that's it). This is my GunController class: ...
-1
votes
1answer
61 views

shooting the projectile in the way it is facing [duplicate]

I got my projectile facing the right way thanks to @S. Tarık Çetin. But now I want it to move the direction it's facing. I think I need to use RayCastHit2D but I am not sure. If I need to use ...
1
vote
0answers
29 views

XNA Deserialization Error: XML element “Type” not found

I want to deserialize an xml file that contains a path for an image I have 3 projects: One with the Program.cs class and the main template stuff from xna, another with classes such as the default '...
1
vote
0answers
38 views

How to color individual parts of curve in unity, real time?

So I have a mesh curve that I've imported from Blender. What I want to do is to place individual points on the curve (at fixed distance) and then based on a specific number, color them. Let's say for ...
1
vote
1answer
171 views

How to load sprite from JSON?

i know how to load text, but idk how to load texture from json.. this my c#: public void soalbegin(){ filepath = System.IO.Path.Combine(Application.streamingAssetsPath, "soal.json"); ...
1
vote
1answer
27 views

How can I use a display as a background in unity?

I have a dancing game that I am trying to make and I have a stage where a character dances and a script to switch cameras inside that stage. What I am trying to do is set those cameras to display 2 ...
0
votes
3answers
128 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- ...