Questions tagged [c#]

C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.

820 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
3answers
3k views

Preventing a Combination of Rigidbody Jump Force & Bounce Magnitude in Unity3D

I'm building a fairly simple marble racing game in Unity3D. The ball is a 3D physics object that moves only on the X and Y axes. It has the ability to roll left and right, and to jump. Pretty basic ...
9
votes
1answer
984 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 ...
6
votes
2answers
2k views

NegaScout with Zobrist Transposition Tables in Chess

I'm trying to put Transposition tables into my alpha beta scout. I do see an incremental speed boost I think toward mid or late game, however, even with a table size of 1-2GB, its may or may not be ...
5
votes
1answer
233 views

How can I Implement spin in billiard game?

I'm not sure that you played billiard or snooker before.if you played you should know about spin. but anyway if you don't know about it you can see it in this video I want to Implement spin like this ...
5
votes
2answers
724 views

Snake movement in monogame

Noobie here... I've started learning monogame development and currently working on a simple snake game. I'm having trouble with the snake's movement, I figured I could make it tile-based movement but ...
5
votes
0answers
977 views

How do I make volumetric grass?

I've been extremely interested in volumetric technology, especially for grass. Online resources are extremely scarce on this topic. What is the difference from creating a lot of mesh billboards? ...
5
votes
1answer
218 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. ...
4
votes
1answer
2k 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 ...
4
votes
2answers
520 views

Touch taps only on very short flicks on Win7 with Monogame

I have an application on win7 which needs to support touch and mouse input using monogame. But reading touch taps proves to be a very hard thing. The TouchPanel is initialized like this: ...
4
votes
1answer
440 views

Problems with Raycasting Requirements

Im working on a script which kinda works like an Enemy AI. Its kinda like a detection system with requirements that are required to be met. This is a recent question i asked using my code Raycast ...
4
votes
1answer
3k views

CPU Usage and Available Ram in Unity 5

In Unity 5 I would like to be able to print out the CPU Usage and Available Ram left in MB. I followed the code posted on http://zamov.online.fr/EXHTML/CSharp/CSharp_927308.html and used it, however ...
3
votes
0answers
50 views

Limit mouse movement within 2 points

I have a circle sprite that i only want to move between 2 empty game objects (points). Using Vector3.Lerp() I'm able to move the circle between those points ...
3
votes
0answers
127 views

Unity3d: calling a web service in unity editor works, but not in standalone. Why?

I have this line of code: SDE3D _webService = new SDE3D(); int result = _webService.UserLogin(txtLoginUsername.text, hashString); My ...
3
votes
2answers
1k views

How do I resolve the error “Trying to send command for object without authority.”?

I don't know what I did wrong I tried couple different ways from not using commands to using SpawnWithClientAuthority. But It either gives build and compile errors ...
3
votes
1answer
235 views

Trapping Asserts in Visual Studio

I'm writing a 2D game with some fairly complex off-screen logic, with plenty of room for bugs. My usual habit is to write code with a lot of Asserts in it. When an Assert gets hit I drop into the ...
3
votes
0answers
2k views

Procedural Islands Voronoi Pattern

I'm trying to keep this as simple as possible, as I've found out the last few days this is a very difficult topic. I'd like to generate multiple flat islands, formed by a voronoi diagram. I've ...
3
votes
0answers
53 views

Why does interactive cloth not appear in game view in unity5 Pro?

I used interactive cloth fir flags in unity5 Pro version and it appears in scene view but does not appear in game view while playing. What can I do for that please somebody help me out?
3
votes
2answers
396 views

Collision detection problem in XNA4/Monogame

I have been trying to get 3D collision detection working for a while and I think (hope) you people can help me. For my project I have created a 'sprite3d' kinda class which is called ...
3
votes
1answer
912 views

3d Wall sliding collision

I'm working on collision for walls in my game and the way I currently have it I get stuck walking into a wall. I'm trying to make my character slide on the walls but still collide. My character moves ...
3
votes
0answers
3k views

XNA Screen Manager problem with transitions

I'm having issues using the game statemanagement example in the game I am developing. I have no issues with my first three screens transitioning between one another. I have a main menu screen, a ...
3
votes
1answer
1k views

How to code a non-newtonian spaceship control script?

I'm working on a simple 3D space combat game, and I've decided to go with simplified physics over proper newtonian motion, similar to the space sim Oolite, and more 'arcade' style games. I basically ...
2
votes
0answers
38 views

Why isn't my method an option for onClick?

Update: The problem went away when I restarted Unity and tried again. The problem I am using Unity 2019.1.8f1 Personal with Visual Studio for Mac 7.8.4. I have a button named ...
2
votes
0answers
70 views

How to create a tube 2D in unity

I want to create a 2D tube in unity which I can cut, suture and drag it, My idea is to use a small image in form of fragments but how i can do it like the picture bellow EDIT : What I did until ...
2
votes
1answer
117 views

Which Pathfinding Algorithm is Best For My Case?

I'm creating a top-down space shooter game where there is no real "map" per say since there is no real terrain, but there are obstacles in the form of asteroids, other ships and a few circular ...
2
votes
0answers
121 views

What is causing a SIGSEGV in mono_class_vtable_full in Unity for Android?

I'm a developer of a mobile game, and we have Crashlytics in our game. For the latest release for Android, we are having crash reports with the following stack trace, for a number of players: ...
2
votes
1answer
95 views

Create context menu in Scene view

I created some MenuItemfunctions for navigating, which are currently displayed on the menu toolbar. The C# code: ...
2
votes
0answers
79 views

Quest UI Display in Unity 2D

I have this quest manager script where I store all my quests for easy duplication. I'm adding a feature that gives the player the option to see his/her current to-do quest. The first thing I ...
2
votes
0answers
256 views

Using C# summary documentation as tooltip in Unity

In unity, I often end up with duplicating the tags for code documentation, and the [tooltip] tags for the Unity Inspector. Is there a way to automatically extract tags into Unity [tooltip]s, or ...
2
votes
0answers
39 views

Sprites being skipped over in simple sprite change script

Each instance of the prefab in question has a copy of this script on it, but they seem to be interfering with each other in some way. I would forego prefabs, except the final game I'm prototyping for ...
2
votes
0answers
352 views

Why doesn't the Camera.pixel(Height/Width) match the Canvas size?

I am making an app that has a custom viewport Rect like so: When I check the sizes of this viewport rectangle in pixels with Camera.pixelHeight; Camera.pixelWidth,...
2
votes
0answers
184 views

Viewport not matching Window size when fullscreen

I am using: GraphicsDevice.Viewport.Bounds to determine the size of the canvas / stage for my window. This works well if I am in Windowed mode, but if I launched ...
2
votes
0answers
158 views

Pre-Hash Input Strings in Unity

So with the new Animator system, Unity has smartly allowed us to pre-hash the strings for looking up variables within the Animator state machine, using the Animator.StringToHash static method. This ...
2
votes
0answers
92 views

How can I move the Player around the space station using the doors as waypoints?

The doors open automatic when the player is getting close to them and then close when the player get some far distance from them. Each door is built from door_right and door_left and I made that each ...
2
votes
0answers
54 views

Why the variable height value is all the time 0?

...
2
votes
0answers
260 views

Fog of War in Unity

I know that my question will not fall into the type of questions normally asked here (no coding presented). I just need some tips and advise on how to proceed (e.g. pipeline or something). I'm making ...
2
votes
0answers
249 views

Why am I getting errors like these when trying to build my app

I am currently trying to build and publish my app to the universal windows platform halfway through the process of doing so, during the validation process I got stopped with these errors. The 1st one ...
2
votes
1answer
394 views

Efficient 2D grid overlay on tiles without each cell being its own GameObject

So for my game I need the ability to add a grid overlay over my tilemap. Now I don't think that making the grid with each cell being its own GameObject with some SpriteRenderer would be hard to do but ...
2
votes
0answers
595 views

Unity2D: Proper way to implement ladder climbing with a raycast controller?

I originally posted this on Stack Overflow, but was told I might have more luck here: I've been slowing grinding out programming features for my character controller, and one of the last things to ...
2
votes
0answers
336 views

Simulating Water by changing Y values of Quad Vertices

hopefully this isn't too difficult to answer, but I'm stuck and could at least use some input. I'm working on simulating water for the first time with basic wave functionality. As in I click at a ...
2
votes
0answers
81 views

Unity 2d - rigidbody rotating Z axis if hit something

I have problem with my player. I use rigidbody2D on my player and I had fixed rotation on Z, but now i need use rotation with some of my root animation. Ok, i enabled it, but when my player hit ...
2
votes
0answers
368 views

Find Max Line Count for Unity UI.Text

I'm trying to determine the max line count of a UI.Text with VerticalOverflow set to truncate...
2
votes
0answers
53 views

How would one get the pixel value of a texture under the cursor?

I have a requirement to detect which pixel of a texture is under the cursor in the 3D world. I assume that Ray casting is involved however, after that I'm not sure how one would accomplish this. Can ...
2
votes
0answers
860 views

How can i instantiate empty gameobject to be position to existing already gameobject?

When i click on keyboards for example dfrg i want that if i click on space it will add empty gameobject right after the letter g like a space for example: drg hello So there is a space after the ...
2
votes
0answers
432 views

Making generic type T method as a layer of abstraction for Unty3D's EditorGUI field draw methods

I am making a visual tool for Editor Window on Unity3D, and I am just recently using System.Reflection methods to get class's assembly data, to get information about properties, fields and methods (...
2
votes
0answers
146 views

Design pattern for world objects caching

I'm developing in Unity a voxel-generated terrain and I'm trying to find an extensible design pattern for voxels and more in general, world objects caching. E.g. storing in a 'ChunkCache' class only ...
2
votes
0answers
128 views

Procedurally generated paths with intersections

The Problem I've been attempting to create some procedurally generated paths for a while now, but I've reached a problem when it comes to generating the intersections of the paths. The paths are ...
2
votes
0answers
706 views

Simple 2D Fish Obstacle Avoidance

I am currently working on a simple obstacle avoidance system in unity. I have a player and a school of Ai fish that are traveling in a fixed direction (Down-Right). While swimming, I want the Ai fish ...
2
votes
0answers
242 views

How to make sure two Tiles not overlap each other?

I'm trying to make a Grid who will be easily convertible between 2D and 3D and I'm having a problem with overlapping prefabs in the case of the 3D generation. The thing is, the DataObjects (Tiles) ...
2
votes
0answers
106 views

Monogame resizing GraphicsDeviceControl in WindowsForms?

I'm currently working on a custom Map editor using Windows Forms. I have a class inheriting from GraphicsDeviceControl (called MapDisplay) that I'm using so that I may use spritebatch to draw the ...
2
votes
0answers
522 views

Are there performance benefits to using WaitForSeconds vs checking elapsed time in FixedUpdate in Unity?

I was considering that perhaps just checking the time and then doing some work in the Update function might look cleaner than calculating how long to wait for and calling yield new WaitForSeconds() on ...