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
34 views

Collision method only using one item from list

I've made a temporarily method for collision with all the blocks on the screen. (I used almost the same method in the past, but only for one block at the time.) So I start in the Sprite class. I use ...
-5
votes
2answers
284 views

Unity Renderer.bounds issue?

I would like to make rend.bounds.max.y be always equal to 20 on collision no matter what, using the script below. But it seems that I can't set it manually and the script has no effect on my ...
-3
votes
2answers
119 views

My Simple Score System Isn't working please help [closed]

using UnityEngine; /// Handle hitpoints and damages public class HealthScript : MonoBehaviour { /// Total hitpoints public int hp = 2; /// Score System public int score; /// ...
3
votes
1answer
97 views

Unity3D Pathfinder with Crossings

I'm trying to bring traffic on my street system. The main problem for me are the different lanes and crossings and to make it complete the different types of paths. I've tried a bit with the ...
5
votes
2answers
582 views

Can you write the current frame number to a text file?

I am running an experiment in Unity 5 to see the effect increasing the particles of a particle effect has on FPS over time. (this is background work for a much larger piece of work). Currently I write ...
1
vote
0answers
56 views

How I can get the time, where I am in a map for osu?

How I can get the time, where I am in a map for osu??? I need an osu!api solution, and I want to get this value: 0:05.12 or something like this.
1
vote
0answers
105 views

Drawing objects in view of camera only in XNA/MonoGame

I am working on a Tower defense style game on mobile that uses a tile map and I am trying to determine the best way to draw overlays of those tiles. In my game, I go into build mode to build towers. ...
4
votes
1answer
179 views

AI using character controller makes unwanted change to it's y position

The enemy parent object does not have any colliders except for the character controller. It starts out with y = .57 and immediately jumps to y=1.6355 because of my call to CharacterController.Move(.) ...
1
vote
1answer
67 views

How to show specific item in question on trigger entry? (Unity & c#)

So I have multiple, random objects on a plane, and when my player walks into them, I want them to be 'picked up'. The player can only hold one object at a time, and needs to return the item to the ...
0
votes
1answer
77 views

XNA Platformer - Where should tile collision handling be?

I've started using XNA and am working on a simple 2D platformer (single level). However, I am stuck as to where the collision detection should be handled. Here is my current project structure: The ...
1
vote
2answers
65 views

What's a simple way to send statistics from my game back to me?

For example, I set up my game to keep track of how many times people play x, y, and z game modes, and also to keep track of how often players reach a certain point. What's a simple way to send this ...
0
votes
2answers
109 views

Reading XML working in my computer but not in my Android phone

Following code works perfect in my computer but when I try to run it in my Android Phone, it does not work. string path = @"Assets\Layout\XML\file" + select.ToString() + @".xml"; XmlSerializer ...
1
vote
1answer
45 views

Collision box to slow

I've made the collision box for my player (and other blocks) and I'm now testing gravity and collision on the player. What I saw was that my collisionbox is updating slower than my player is moving. ...
0
votes
0answers
38 views

Problem with collision between two farseer bodies

I have four different bodies. Ground, rectangle, red ball, white ball. The rectangle and the ground are static. Just the balls are moving. The red ball can´t move through the rectangle, but the white ...
0
votes
1answer
48 views

Doesn't Unity5 support Expression Bodied Properties?

I wrote the following line in Unity5 using C#: private static float Width => 0.015f; Unity complained about the following issue: Unexpected symbol `=>' in class, struct, or interface member ...
0
votes
1answer
101 views

Unity3D Making timescale freeze and resume

So, I'm trying to make it where when a popup(Ui panel and text) appears, the game's time(timescale) would freeze. Then when the user enters input and clicks enter button, the popup would disappear ...
2
votes
1answer
172 views

Attach to a GameObject after collision? [duplicate]

How can I make a GameObject attach (or "stick") to another GameObject after collision? The problem: I want the GameObject to attach after collision even if it changes scale. What I have tried: ...
0
votes
2answers
234 views

How to handle multiple enemies with the same script?

i'm working on a basic Top-Down Shooter, kind of like... Nuclear Throne or The Binding of Isaac, but since i'm new to Unity, and it's something i'm required to do for school, i'm quite in a rush so i ...
1
vote
1answer
80 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 ...
1
vote
0answers
52 views

How to create offsetting lines that draw across the screen in Monogame?

I'm trying to create an effect on the screen like the gif below. Basically lines that are offset by 1 pixel draw across the screen from either side which then eventually creates a solid color. I'm ...
2
votes
1answer
99 views

Move two different objects to two different destinations so they arrive at the same time without using lerp

I might be missing some simple thing but I'm not I am able to wrap my head around this. Normally, if I want to move two objects to different positions so they arrive at the same time I would use a ...
3
votes
1answer
803 views

Triggering animation in character OnTriggerEnter?

I've been stuck on this for hours. I have a character whose animations are based in mecanim to transition based on the bool variable ShivaEnter. One invisible cube is set to change the bool value ...
9
votes
0answers
133 views

Dual Contouring - Finding the feature point, normals off

I am following this tutorial to implement Dual Contouring http://www.sandboxie.com/misc/isosurf/isosurfaces.html My data source is a grid 16x16x16; I traverse this grid bottom to top, left to right, ...
-3
votes
2answers
124 views

Smooth GameObject Rotation

I want to rotate a 3D GameObject from 0 degrees to 180 degrees on the Z axis smoothly at a speed that I can define. How can I do this?
3
votes
2answers
170 views

How to avoid Walls in A*

Well I had a problem with the implementation of my A* algorithm in C# for unity, and I don't realize how to prevent the diagonal movement and the cross walls, I had the next code, the print line's are ...
2
votes
1answer
151 views

Why doesn't Array.Copy to mesh.verticies work in Unity?

I am rebuilding a mesh but something seems odd that I have to create a temp array just to hold the verticies rather than copy an array. I'm not using list because this is used frequently and I do not ...
3
votes
1answer
69 views

Refill lives after application exit

I try to implement refilling lives functionality after exit application. Every live is refilling after 25 minutes, but unfortunately only if the user is in the game. Here is the sample code: private ...
3
votes
1answer
48 views

Finding vector from a vertex to a plane

I am trying to implement Dual Contouring, following serveral sources, mainly http://www.sandboxie.com/misc/isosurf/isosurfaces.html but now I want to implement finding the feature point as explained ...
0
votes
2answers
499 views

Using Unity's `transform.translate()` to translate relative to an object but only using two axis

I'm using transform.translate() to move an object around the world space, relative to the camera that is following it. The camera has an angle of 23 degrees on the X axis. The problem is that when I ...
0
votes
2answers
55 views

Using Content.Load<>() in a class that is not derived from Game

I have a class (SpriteManager) that is not derived from Game || DrawableGameComponent || GameComponent so I use my custom methods. When my game starts, it runs that class. My question is, how to use ...
-2
votes
2answers
77 views

Increase Y position on MouseButtonDown?

How can I increase the altitude of a GameObject as long as if (Input.GetMouseButtonDown(0)) is activated? "The longer the button is pressed the higher the GameObject goes." I also want to show the ...
0
votes
1answer
136 views

Unable to rotate GameObject properly?

My GameObject is able to jump towards a moving target (another GameObject), thus adjusting its trajectory - while simulating gravity (as in the .gif). I want to make the "jumper object" rotate. But ...
3
votes
1answer
90 views

Adding class to Game

I work on a little project, and in the past, I used SpriteManager : DrawableGameComponent as my SpriteManager class. I have been told that DrawableGameComponent is not so recommended to use, so I ...
3
votes
3answers
525 views

How to create a delay/timer and fire an action once it expires in C# Monogame? [duplicate]

First off I'm somewhat new to C# but I'm working on a game in C# Monogame and I'm trying to get timers working. There was a similar question answered around here a while back but I found that the ...
2
votes
1answer
73 views

Sound and Unity 5

I want to work on sound in games, but I don't have any experience in scripting, only in sound design for film. Some friends that do know scripting are starting to learn in Unity 5, and my part would ...
5
votes
4answers
237 views

Creating force shields: the most efficient way of deforming/reshaping a simpler convex mesh so it envelopes a complex mesh?

So, the best way I can think of how to explain what I need is the following (images used here are just random images found trough google image search). What I am trying to create during run-time is ...
7
votes
1answer
690 views

Adding multiple game objects into a prefab

Is it possible for one prefab to contain multiple game objects, preferably in a parent-child relation. I am making a complex enemy that I want to separate into a couple of game objects with separate ...
5
votes
1answer
147 views

Finding new position after collision with multiple colliders

What is the most accurate way to find the correct position to where a moving character should be re-positioned as a collision-resolution, after it has collided with multiple colliders? The figure ...
7
votes
4answers
653 views

How do I wait to execute code?

I'm trying to make a relatively simple elevator (which essentially teleports the player), but I don't want it to instantly teleport them. I want the player to enter the collider, wait 2-3 seconds, and ...
1
vote
1answer
69 views

Inherited property in derived class reference only base class

[Context] I am developing a game in Unity, and wanted to make a Game Manager. Like many examples out there, it uses a Singletron design pattern. But i have several other Managers, all using Singletron ...
1
vote
0answers
178 views

Cant load model from Content in latest Monogame version

Using MonoGame 3.4, I'm trying to display a simple textured basketball. Within the Game1 class, I've created Model mModel. My Initialize function contains all the proper Matrix information. When I ...
6
votes
4answers
114 views

Check whether a game object is inside the boundary

I'm developing a small children game similar to Paperama. Here the player can scale rotate and move the object anywhere in the screen and the player should fit it in the boundary. I'm okay with ...
-2
votes
1answer
56 views

Where to put the script? [closed]

I watch this video https://www.youtube.com/watch?v=Uhnh8zj_VPo and my question is where to put the script? I'm a complete noob here but I've at least build a map and moving player character. Yes, ...
2
votes
1answer
970 views

best way to destroy an gameobject in unity

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the ...
2
votes
1answer
107 views

Collision detection

So I've made my collision boxes visual (Draw method) and I saw that there were some problems with the boxes and I fixed them (x, y, length, width). They are now big enough. This is the collision box ...
0
votes
1answer
122 views

Stop detecting Input in Unity?

How can I stop detecting input from the user in Unity? I want to achieve the following: "do not detect Input.GetMouseButtonDown" In C#?
2
votes
2answers
76 views

How do I make my character change his ability's when his sprite changes

I am making a platformer and am currently trying to have it so that my character will have different powers based on his emotions, and his sprite will change to match those emotions. I have got it ...
4
votes
1answer
254 views

Unity3D multi-threaded data importer?

Goal I would like to be able to separate all my data file readers from the main thread and balance the load over multiple frames. The idea being that while the data is being read/parsed/filtered I ...
1
vote
0answers
27 views

Universal App: Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED) [closed]

I have problem with creating xaml control. I write new project in VS 2015 in universal app. this is my code: <ItemsControl Grid.Row="1" ItemsSource="{Binding Path=TechnologyList}"> <...
-5
votes
1answer
305 views

Check elapsed time in Unity?

How can I check the elapsed between two intervals? I want to do the following: "start time counter when Input.GetButtonDown("Fire1") , stop counter when collision is detected` And then Debug.Log the ...