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

How to rotate a gameobject to the specific angle

I have tree model that is being rotating .After certain angle it should stop rotating.I have done a sample code.But the tree is not stopping. void Update () { //transform.Rotate ...
0
votes
1answer
17 views

Unable to get object to rotate to looked position?

I'm trying to get an object to smoothly rotate towards a clicked point in my terrain. However, my code only yields jittery movements in the other direction. Any help will be greatly appreciated. ...
0
votes
2answers
54 views

How do I trigger OnSelect() via the ISelectHandler in my class?

I'm trying to figure out how I can make a custom UI element identify when it has been selected or deselected. Classes such as Selectable inherit from the ISelectHandler and IDeselectHandler and their ...
0
votes
1answer
39 views

What is the difference between a game object being disabled and it made inactive?

I am looking over a script that has a particular function called to disable the script and mark a list for re-structuring: void Disable() { gameObject.SetActive(false); isEnumerated = false; ...
0
votes
2answers
27 views

Getting unit to complete rotation before moving?

I've been trying to get a unit in my project to move in a fashion similiar to that of modern MOBA games. However, I am faced with the issue of the unit moving before the rotation is completed and the ...
2
votes
1answer
76 views

Prime31 Plugin Error : “Plugin 'P31RestKit.dll' is used from several locations”

I got the following error, when i tried to install "Prime31: MicrosoftAds_2015-04-22" plugin in Unity 5 Plugins colliding with each other Plugin 'P31RestKit.dll' is used from several locations: ...
0
votes
1answer
37 views

Enemy AI with Rigidbody - Floating in the air

I'm working on my enemy AI scripts and I'm using a rigidbody to have the enemies chase the player when the player gets into its aggro distance. Two of the main problems I'm having: When the game ...
0
votes
1answer
22 views

Getting curved-based zooming speed?

I am able to get a fairly smooth zooming function going on in my project. However I'm hoping to achieve a non-linear function. I've tried using the smoothstep function but it doesn't feel smooth ...
0
votes
1answer
187 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 ...
0
votes
1answer
189 views

Remove item after crafting

I'm having one last problem with my crafting system. Say an item takes 2 rocks, 1 twig, and 1 vine. When I craft the item, only 1 of each item is removed instead of the correct amount of items related ...
0
votes
3answers
145 views

Detecting on which side did the objects collided unity 2d

I have a ball and a rectangle in my game. The rectangle has a box collider 2d attached to it. How can I calculate or check when the ball hits the top of my collider, when it hits the bottom, left and ...
1
vote
1answer
1k views

Getting a pixel of Sprite at the cursor position in Unity

Summary: I've been trying to figure out a way to use simple box colliders as a nice and efficient "first pass" collider. For the "second pass", I want to check that the area clicked has an alpha value ...
0
votes
0answers
27 views

Mesh tilemap and scrolling

I'm working on a top-down game where the player can move up, down, left, or right. I've come across tilemaps but since using Unity, I'm seeing the idea of using Meshes. I don't quite understand how ...
1
vote
1answer
851 views

Clipping polygons in XNA with stencil (not using spritebatch)

The problem... i'm drawing polygons, in this case boxes, and i want clip children polygons with its parent's client area. // Class Region public void Render(GraphicsDevice Device, Camera ...
1
vote
1answer
26 views

Update total enemy counter after single enemy is defeated?

So I have a list that counts how many enemies are in the area. But when I kill an enemy, the list shows that that element in that array is missing, and doesn't reduce the enemy counter. How can I get ...
2
votes
2answers
93 views

2D Simplex Smooth Cave Generation

So I'm creating a system of caves below my random terrain generation, and I'm using 2D Simplex Noise to do so and I have a pretty good grasp on generating the random caves. However, the cutoff from ...
0
votes
3answers
86 views

How to change the gravity with a click

How to change the gravity of a ball upward with a click Then change it again downward with another click And so on In unity
4
votes
4answers
167 views

What are the differences between using “GetComponent<Transform>()” and this.transform?

I've been reading some example codes and working on my own stuff in Unity. I've been seeing a lot of GetComponent, and often this will be done for the transform: Transform _transform = ...
0
votes
1answer
85 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 ...
-4
votes
0answers
26 views

How can I add a force to a gameObject when I touch UI button in unity 5 [duplicate]

I'm using unity 5 How can I add a force to a gameObject when I touch UI button I want the ball to jump when I press that UI button
0
votes
1answer
81 views

Unity: Object is underneath another object but shouldn't be

I have a simple collision detection program. The red object is controlled by the user and the yellow object is always moving up and down: However, when the objects are supposed to collide, the red ...
2
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 ...
1
vote
1answer
116 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; ...
1
vote
1answer
2k views

Changing color of UI Text in Unity into custom values

There are a few objects in the scene as well as a title. I want the title to change its text and color based on the object that is mouse-overed. The script below is added to each object that is ...
-5
votes
0answers
41 views

First game job in UK. Engineering school but not experience in the field [duplicate]

I am about to relocate in UK, in any town. I would really like to work for a gaming company. However, almost all big studios have as a requirement to have similar work experience in an AAA title. Or ...
0
votes
1answer
43 views

Getting position of finger along a screen

I'm trying to get a list of Vector2 position by tracking my finger and then tracing them with a prefab (Basically just gestures). I have appended an onGUI function to help print out the list of ...
1
vote
1answer
60 views

1D Simplex Noise Returns Same Generation

I've been using 1D Simplex Noise to create a random world surface, and it keeps generating with the same looking surface terrain, with some minor variations. Here is my sample code- Tile[][] tiles = ...
1
vote
1answer
173 views

How i can do colisions with irregular hitboxes [XNA]?

I'm developing my new platform engine and i don't know how to program collisions with slopes - I'm using hitboxes. For the collisions of rectangles i use this: if (player.rec(Position, ...
0
votes
1answer
47 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 ...
0
votes
1answer
91 views

finding a path from one point to another with obstacles help

Im building a tile based game and im implementing my path finding algorithm. Currently, it can find a path from point A to point B with no problems. However, if there are obstacles between point A and ...
3
votes
1answer
130 views

Fade between scenes

So I have googled how to do this already but all the answers were for older versions of unity and use things that are not applicable anymore. I am trying to do is fade the screen to white when the ...
2
votes
2answers
287 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 ...
2
votes
1answer
103 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
0answers
30 views

Unity Input manager with chain of responsibility and delegates

I am working with unity and I am trying to build a better input system for my game. In essence there would be a singleton class that is the input manager. The player would subscribe to the manager ...
2
votes
1answer
88 views

What is a reasonable way to avoid GC issues in Unity?

I've been reading about how garbage collection is a big problem when programming games using C#, Java, and the like - if you have a large amount of objects, the GC will run sporadically and scan ...
0
votes
2answers
158 views

Rotate an object smoothly by 90 degrees on key press in unity3D

[I saw few similar question on stackexchange but none is solving the purpose.] I want to rotate a 3D object by 90 degrees on different axis on respective inputs. For example if 'a' is pressed, the ...
0
votes
1answer
30 views

Unity3D - Change player input axes on trigger

Hope someone can help me with this, it seems like it should be a simple problem but that only makes it more frustrating! I have a simple game where you roll a ball around by applying force to the ...
0
votes
1answer
39 views

Rotation with respect to world instead of the object itself using Quaternion.Euler in unity

[Other answers on similar questions on stackexchange didnt help] This script is giving some weird outputs On running this script If I press rightarrow once followed by 's' the object rotates on 'z' ...
8
votes
3answers
7k views

How do I make objects move along a path?

I'm trying to get something like the below image. As you can see, there's a highway and inside of it, there'll be some objects moving (millisecond). I guess the street behavior is like a pipeline. ...
2
votes
1answer
86 views

How can I get the user altitude from an iPhone using Unity 3D?

I can see in the Unity 3D documentation that its possible to get the altitude of the user from their iPhone, but I cannot figure out how to actually do it. I try this code: using UnityEngine; using ...
0
votes
0answers
34 views

Is resource management a good idea when dealing with animations?

New to the Unity environment here and I have a question concerning how to efficiently manage computer resources in a top down 2D game. I have a large area that looks like a 2d rpg from the 90's and ...
0
votes
0answers
63 views

How can I detect collision between two objects

I have some code that when I click on an object with my mouse it will change it to another object. I'm using this code to change an object into a shattered version I made of it for destruction ...
2
votes
1answer
110 views

Blur effect on background to make the forground more clear unity

I'm making a game in unity and I'm trying to add a background blur effect to my game to make things a bit more clear. Here is an example of what I am looking to do: I'm trying to get the background ...
0
votes
1answer
39 views

My sprites are spwaning on top of each other with a new class?

I am making a game for college in XNA C#, however I have got to the point where I need some enemy sprites to be spawned in for the player to shoot. I did this with one enemy by itself without using ...
-1
votes
1answer
26 views

Players Health getting recuded only once when attacked [duplicate]

I made a game in Unity 2D Issue: I have made some spikes and other aliens, which decreases the players health if they come in contact. The health only decreases once instead of getting decreased ...
3
votes
2answers
268 views

How to use an A* Pathfinding System across uneven environments?

I am developing a game in Unity3D. I want an enemy character to follow the player around. The problem is, my surface is uneven and full of mountains. I am using aarongranberg's pathfinding project. ...
2
votes
1answer
148 views

How to implement a professional fighting game input buffer?

Ok guys, I understand how to make a basic input buffer. Here is my code: public class InputBuffer : MonoBehaviour { public int max_buffer; public enum keys { down, up, left, right, X, Y, ...
0
votes
2answers
41 views

How to prevent the player from calling the Jump function if no collision is detected?

I am back once again. This time with a basic 2D platformer game. I would like to allow my player to jump but only if the ground bool checks as true. I would like to fix my script so that upon ...
0
votes
1answer
82 views

Unity - “SetDestination” can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3)

I'm using Unity5 right now. I got this error when try to setDestination. "SetDestination" can only be called on an active agent that has been placed on a NavMesh. ...
0
votes
2answers
84 views

How can I determine the number of pixels drawn within a predefined shape on the screen?

In the image above, I want to know how can I calculate the number of pixels of the rendered players' shadows that are inside the elephant outline. An occlusion query is used to count the number of ...