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

1
vote
1answer
117 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
640 views

Sprite collision with color?

Is this possible? To elaborate, I am making a PacMan offshoot. Essentially it is a "zoomed in" version of the game, but the board is randomly generated. I have 11 .png files each to be used as a ...
2
votes
3answers
277 views

Jumping higher when the player touches a trigger collider in Unity

Im using Unity engine to create a 2D platformer. My character can single/double jump, this works fine everywhere except when i am in range of a collider with a IsTrigger set to TRUE, then my character ...
1
vote
2answers
2k 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 ...
0
votes
1answer
248 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 ...
0
votes
2answers
268 views

How to make a gameobject Scale up from another GameObject script

hi there im having a rought time with this code, trying to make a gameobject grow in scale from touching this one, and when a set amount of scale is reached destroy this game object ( the one who ...
1
vote
1answer
84 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
1answer
261 views

2D game world engine

I'am starting to develop a 2D game with snake or worm. My question now is: When my snake reaches the right edge the world should move. (Like in this game) My first thought was to implement a camera ...
1
vote
1answer
479 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 ...
0
votes
2answers
3k 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 ...
0
votes
1answer
104 views

AABB collision resolution issues

I'm trying to make a character collide with some tiled terrain. I have an issue with the collision resolution, and after days of shooting in the dark ant not finding any relevant help online, I'm no ...
0
votes
2answers
2k views

Play animation when click on each player with in maincamera unity3d

I have 3 gameobjects (player1, player2, player3). I attached a script "playerscript" to these game objects. In the main camera, I have added another script called "testscript". Clicking on a player ...
0
votes
1answer
124 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
28 views

Instantiation of multiple objects with varying velocities

I am looking to multiple objects of the same prefab at the same time with varying velocities. public GameObject prefab; public float xDirection; public float yDirection; void Update () { ...
0
votes
3answers
62 views

2D Physics friction on a moving platform?

I have a few basic platforming mechanics going on in this scene. I have a prefab platform with an animation that loops back and forth between two different x positions, but does not begin looping ...
1
vote
1answer
94 views

Should frame update and network packet sending synchronous or asynchronous?

I am making a game server that has 60 Update-Per-Second (assume I can most of the time achieve it). In the current model, my main loop does the following tasks in sequence: Update game logic ...
0
votes
1answer
50 views

Unable to Set Text of another Text Object

The Idea: Pressing a button in the canvas will allow the player to select a race. A script is attached to an object which is accessed though the OnClick() function of the button. The script is ...
1
vote
2answers
48 views

Rotation before scaling image/Lower resolution rotation? (XNA/C#)

Currently, when I rotate the image using SpriteBatch.Draw() the image is rotated after it is scaled. Resulting in: Which is using the code public override void Draw(GameTime gameTime) { ...
0
votes
1answer
56 views

Unity5x GetComponent<Animation>().Play(“sequence”.StopAll) not working

I'm working with Unity3D 5x using C#. I've attached collision detection to the character controller script that plays a "gothit" animation clip (using legacy animations). Here are the code snippets, ...
1
vote
1answer
59 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
243 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 ...
1
vote
2answers
84 views

How to know from which direction there is a collision with an object? In Unity C#

In the game, there is a ball, and moving objects that can hit it. I want the ball to move when an object hits it. But the ball should move to the right direction, the one which the collision was from. ...
0
votes
1answer
227 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 ...
1
vote
4answers
376 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 ...
3
votes
1answer
63 views

How can I make a scrollable text view?

I am trying to do an appication in monogame windows. I have a long text to be displayed on screen. I tried to render it on screen using spriteBatch.Drawstring, was succesful to an extent. But, the ...
0
votes
1answer
30 views

My GUI stopped working?

Okay I bought this asset online so I would like not to show the whole script. The problem is this asset stopped working when I updated from unity 5.0 to 5.1.2. The script is for a controller GUI ...
0
votes
1answer
28 views

Stop player following cameras cameras direction

Okay I'm not going to go to much into it but this is what I need my script to do. The way I have my controller set up is that the camera looks to the side of the player a little bit. I use this for ...
0
votes
1answer
53 views

FPS horizontal smooth camera rotation

I have a problem, my camera is parented to the FPS Controller prefab, then there is a script I wrote for the rotation of the player horizontally by mouse movement, it all works but the rotation is ...
1
vote
1answer
31 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 ...
3
votes
2answers
222 views

2D Collision Detection XNA C#

I've read all around the net, watched videos, tried things and in the end I can't make a decent platform collision detection. I've followed this tutorial. It didn't work out at 100%. My object stops ...
-4
votes
2answers
37 views

I want to now how to set. X to a spot and change it to a cord but. Keep my Y and Z [closed]

Let's say postion was X1 Z34 Y2 I want to move char to X2 no matter what Z or Y are I want to change my x and keep z and y the same and keep momentum
2
votes
2answers
441 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
38 views

Card/Tile Game, loops dont update element0 of playerHand properly

The Problem I am dealing from another class and into a player's Tray(A class with a List of Tiles and an array of bools to show that a slot in the tray is full). When dealing into the player's tray, ...
0
votes
0answers
25 views

Position is not what it should be when attaching fixture

In XNA / Farseer I have something like this: Body body = BodyFactory.CreateRectangle(world, 1f, 2f, 1f); FixtureFactory.AttachCircle(0.5f, 1f, body, new Vector2(0f, 1f)); I have been told that ...
9
votes
4answers
3k views

How can I build a game in Unity with minimum/no use of the visual editor?

I'd like to write a game completely in C#. In my search for an engine, I found Unity3D, but all the tutorials and documentation are speaking about a visual editor and the Unity IDE in which you click ...
0
votes
1answer
132 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 ...
-2
votes
1answer
39 views

Save the screenshot of the scene locally in unity

I have a unity project which contain a button in the scene. I have loaded a terrain also into the scene. When I run the project, the terrain and the button will be shown. When I click on the button, a ...
0
votes
1answer
44 views

SerializeField vs GetComponent Efficiency

As far as I know, there are two built in ways to get an instance of a component in Unity. 1 - Serialize the field and drag in the component manually in the editor [SerializeField] private MyScript ...
2
votes
1answer
141 views

Unity: UNetWeaver warning: SyncVar set from within property function. This will not set dirty flags. How to?

I was trying out the new Unity networking and I added the SyncVar attribute to one of my variables to be synced. I also have a property to get/set the variable and update the visuals when set. I set ...
0
votes
3answers
71 views

Check if body is on the ground

In my game I have an quite irregular terrain at the bottom and a round ball which can be controlled by the keyboard. Is there any way to check, if the ball is currently on the terrain? This is very ...
1
vote
2answers
87 views

How do I refer to the object that called a function?

I have a large number of buttons instantiated from a prefab using a loop, as follows: public void LayoutButtons() { GameObject newCanvas = Instantiate (canvas) as GameObject; for ...
3
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
182 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; ...
0
votes
1answer
51 views

Pass-through pixel shader not displaying properly

I'm new to shaders, HLSL and XNA in general. I'm trying to write a pass-through pixel shader but I'm experiencing some odd behaviour. I created a simple texture, shown below: Here's what I see when ...
0
votes
1answer
34 views

Unity - Jump counter for double jump script not working? C#

It was working fine last night but it doesn't work today, the zJumpCount stays at zero after I jump now. If the zJumpcount stays at zero my double jump code doesn't work. I even ctrl+z'd back to the ...
1
vote
2answers
221 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
57 views

Gravity not being applied to character, using character controller

So I just copy and pasted the unity example class to use with my character controller. public float speed = 6.0F; public float jumpSpeed = 8.0F; public float gravity = 20.0F; private Vector3 ...
0
votes
1answer
33 views

Finding enemy object in player's forward direction within a range

I would like to know the way by which I can find enemy objects tagged with "player" in a forward direction within a range say 3 units from the player.
1
vote
1answer
55 views

Black Rectangle instead of texture

I am trying to draw a textured ractangle like in this example. But instead of a texture the rectangle is just black. Draw method: protected override void Draw(GameTime gameTime) { ...
1
vote
1answer
53 views

How to detect collision position and that position's texture color in Unity?

I have a prefab and I use Circlecollider2D for physics operations. I want to detect the color of the contact position of the collided objects ? Is is possible by using Unity's collider classes ?