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

Random Functions in Unity [closed]

Is their a way to execute or call a random function in unity. Something like:- void Update(){random(func1(),func2())} void func1(){print("func1")} void func2(){print("func2")}
-1
votes
1answer
54 views

What properties should be private, public, and protected? [closed]

I'm currently trying to write a base player class, and I'm not exactly sure what I should make private, and what I should make public. I know that as a programmer, I need to keep as many variables as ...
1
vote
1answer
89 views

Creating a list of buttons dynamically in code

I have a list of contacts. I need to create a scrollable list of buttons that are created dynamically so I can add each contact name as the button text. How would I do this all in code? My biggest ...
0
votes
1answer
55 views

Move around object

I have problem with Unity - 2D objects. I want to rotate object around circle and on click translate it (with same angle) outside the circle to another and still rotate. Rotating is working with ...
0
votes
1answer
32 views

Transforming position in y-axis (going in the middle) in Unity [closed]

I am making a 2d game where an object goes up, down or in the middle with given Input. But when the object goes to the middle with GoMiddle() it starts glitching and it can't go back up or down ...
0
votes
1answer
35 views

2D diagonal movement using Rigidbody2D

I have a problem with 2d player movement, as I am unable to move on the Y-axis. Yet, the movement on the X-axis is working as intended. Below, you can see my code: public Sprite directionUp; public ...
1
vote
2answers
46 views

Randomly instantiate avoiding overlapping in Unity 5

I'm starting a 2D game where I want all the letters A-Z displayed in a random position and, then, the player collects them all in the correct order. I need to randomly instantiate the letters without ...
1
vote
1answer
36 views

Programatically Build List of Custom Class Objects (prefabs)

This seems like it should be a simple thing, but I cannot seem to figure out a method. Currently, I have a public List<MapGraphItem> roomList variable, and in the inspector, I add prefabs from ...
1
vote
1answer
49 views

Unity Rotation - Object is rotating on Z, but should be rotating on X

I've been working on a project where I have a cube. When swiped left, the cube will rotate 90 degrees the left, and then when swiped right, the cube will rotate 90 degrees to the right. I have this ...
1
vote
0answers
30 views

Problem in player Rotation in Unity

I am trying to rotate game camera using my android device orientation.Like this Using accelerometer input of device this may be done. But I don't know how to do this. I tried lot of methods, but ...
4
votes
1answer
88 views

How do I differentiate between the two Vive motion controllers?

I am working with a Vive Pre (devkit) and I have most everything working the way I want it to. However I am wondering how do I refer to or even know which motion controller is which? From what I can ...
3
votes
2answers
74 views

How do you restrict sideway movement in 3D endless runner in Unity?

I have been making a endless runner 3d game and implemented 3 lane side way movement. It's working perfectly, although I want to restrict my movement for the 3 lanes only. If my character for example ...
1
vote
0answers
37 views

Fixing wave-like movements when rotating an object using mouse input in Unity

I have encountered a rather odd issue with my program. The setup: In my scene, I have a GameObject which I have set as my player/character for this game. The player/character has a child GameObject, ...
0
votes
2answers
50 views

Transforming Position in y-axis (going down) in Unity

I want the gameobject to go down (position.y) after pressing a key instead of pressing the key repeatedly. So in my current code the object goes down(0.05f) each time I press a key. But I want it to ...
-4
votes
2answers
90 views

Trajectory Arcs

Ok so I have read this question Calculating trajectory. And it is sort of working in my program. I am trying to produce nice parabolic arcs with this. Like so .. The results I am getting look more ...
2
votes
0answers
33 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 ...
2
votes
1answer
29 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
70 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....
1
vote
0answers
25 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 ...
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
64 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
14 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 ...
2
votes
2answers
33 views

How to access a prefab's boolean property through collision (with the same Prefab but different Instance)?

I am a trying to recreate the first stage of Super Mario Brothers, but I am having a bit of trouble with the collision system between Koopa Shells. I have written two different scripts in hopes to ...
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
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 ...
3
votes
1answer
64 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
26 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 ...
0
votes
0answers
24 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
2answers
37 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 ...
1
vote
1answer
40 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 ...
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....
-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
39 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 ...
4
votes
1answer
169 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 ...
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 ...
1
vote
0answers
31 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 '...
0
votes
2answers
74 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
vote
3answers
66 views

BoxCollider2D Not Working

So I'm making a copy of noobtuts tutorial on Snake - http://noobtuts.com/unity/2d-snake-game I've done all their steps and am at the point of extending the game solo, however I've an issue with the ...
1
vote
1answer
55 views

Unity 3D - Modify a Script on runtime

I am about to make a programming game for children, hence I will use blocks (like Scratch or Stencyl). My question is: Is there a way that you can modify a script (let's say, by adding a string ...
0
votes
0answers
26 views

Unity Networking clientRPC not working

I have a networking game in Unity Version 5.4.0b24, but when i call a [ClientRpc] function from server it doesnt work, gives an error like this: Found no behaviour for incoming [ClientRpc:...
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 ...
1
vote
2answers
106 views

How to make switch work with enum? C# Unity

I'm working on a script to fade UI elements in Unity, similar to a selector, where you can select the type of fading, and duration, and image to fade I found that enum is the best option to achieve ...
0
votes
1answer
76 views

How can I duplicate this color/hue shifting effect in C#?

I am looking for a way to duplicate this color shifting effect: I don't think it matters but the starting frame would be this: My instinct was that some type of hue shift is occurring in a way ...
0
votes
0answers
43 views

Bad practice to create a GameObject for every BoxCollider2D? (Unity)

I am creating a 2D Platformer and need more complex BoxCollider2Ds to be able to handle the collisions (multiple tags, addable & removable properties, etc.). My current solution: Create a ...
-1
votes
0answers
20 views

How can I change this script to follow object [duplicate]

I have that script to follow object by camera public Transform target; // Update is called once per frame void Update () { transform.position = new Vector3(target.position.x, ...
0
votes
1answer
102 views

Obscure primitive data types against cheating [closed]

im trying to create lightweight value obscurer, against possibility to blatantly change primitive values in memory editor. Such as cheat engine. Here's what i have to far. /// <summary> /// ...
0
votes
3answers
81 views

How to find an object which is added to a scene only when game starts?

I'm looking for some advice how to find an object which is added to scene only when the game starts? Before start it isn't in Scene hierarchy. It's prefab.
-1
votes
1answer
46 views

How to write an event + eventhandler? C# [closed]

Hey guys I want to have an event that would be called "OnMonsterKilled" this should trigger when a monster die so hp = 0. Could you give me some good help? maybe with some explanation I'm not the best ...
0
votes
1answer
19 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 ...
0
votes
1answer
51 views

Synchronize objects' movements moved by coroutine function

I'm using Unity version 5.3.5. I'm having problems to synchronize the movement of three different objects from point A to point B and vice versa. To move the objects I use the following code: public ...