Tagged Questions
C# is a multiparadigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
0
votes
0answers
9 views
Zoom only the particular object in unity
I am working on a sample to zoom the particular object when clicked on it.I have used the following code
var zoom : int =15;
var defaultFov : int=60;
var smoothness : int=5;
var isZoomed : ...
0
votes
0answers
11 views
How can I make an expandable menu and assign names to buttons randomly from an external file using Unity?
I'd like to create a menu on the lower left side of the screen which will present some options (guns) to the player. The number of options should change based on how well a player is doing. In other ...
0
votes
0answers
32 views
How to convert a mouse's “On screen” position to “World” position C# Monogame
So the problem is this... I have a top down game, where you click on the screen to select which unit you want to control. You left click to select, and right click somewhere else to tell it where to ...
1
vote
0answers
28 views
How can I change the list of enum options displayed in the inspector?
I have an array of enums:
using UnityEngine;
public class EnumsInInspector : MonoBehaviour
{
[SerializeField]
public EnumType[] myEnums = new EnumType[3];
public enum EnumType
{
...
0
votes
1answer
32 views
Unity3D - How to get highest value for acceleration from Input.gyro
I'm using gyroscope and I need to get highest value for user acceleration (x, y, z axises) from gyroscope
My current code looks like this
using UnityEngine;
using System.Collections;
using ...
0
votes
0answers
26 views
Best way for me to set up my tile grid? (Monogame c#)
I am planning a game with a grid based combat system. I however felt like the grids being set up in more of a parallelogram would be the best angle for the units to be stacked and put on the screen. I ...
0
votes
0answers
33 views
Simple 2.5D flight movement
I'm building a simple 2.5D Dogfighting game, kinda similar like this one: https://gfycat.com/PleasantDeterminedArcherfish for the moment my movement works like this:
if (Input.GetKey("left"))
...
0
votes
0answers
34 views
Unity2D wall jumping not working correctly?
i've been working on this project for the past week using unity engine, its a 2d platformer similiar to super meat boy.I've been able to program jump sustain(jump higher when you press space longer), ...
0
votes
0answers
16 views
Trigonometric movement cause problem when holding player inside bounds
In my game I have a Player class. Here is what it looks like.
public void Update(GameTime gameTime)
{
// Controls
kb = Keyboard.GetState();
if (kb.IsKeyDown(Keys.W))
...
0
votes
0answers
20 views
How to get vectices of a sprite in correct order in Unity?
Currently, when I examine sprite.vertices, I see that it is ordered in crossed way, like: one from bottom, one from up, another one from somewhere else... etc.
I need the correct order to make array ...
0
votes
1answer
11 views
Replace text in Unity [on hold]
i tried to look up my question but didn't really find an answer that works for my situation.
I'm using this unity asset called Dialoguer to create interactive dialogues.
What I'm trying to do is to ...
1
vote
2answers
22 views
Translating a world position to an array position
Lets keep this simple, so, assuming I have an array like this ...
var array = new bool[10,10,10];
.. and then I have a start and end vector3 ...
var start = new Vector3(-21,-21,-21);
var end = new ...
1
vote
1answer
22 views
What is the maximum value of a LayerMask in Unity?
What is the maximum value of a LayerMask in Unity (the value when all layers are included)? And how can I find it using C# bitwise operations?
I tried ~0 but it shows -1 in intellisense.
Thanks in ...
0
votes
0answers
21 views
Save and retrieve image from database in unity
I have done a sample to insert and retrieve data from MySQL in unity.Now I need to insert and retrieve image from MYSQL in unity. The images are files selected by the user from their filesystem.
Can ...
1
vote
1answer
15 views
Unity RaycastHit2D sprites error C#. Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders?
Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders?
Below is the c# code.
using UnityEngine;
// This script allows you to drag this ...
0
votes
0answers
26 views
Where are some good resources to begin learning C#? [closed]
I'm an intermediate Javascript developer and I'd like to begin learning C#. Where do I start? I have all the required software to begin developing, but I don't know what to do.
0
votes
2answers
124 views
Should clients in an online game access the database directly or through a game server?
first im total noob about c# and mysql. Just trying to find which way is better. i believe your answers prevents me from losing plenty of time.
Online game(not more than 50 users at pre-alpha. Not ...
0
votes
1answer
35 views
Rotate a UI Image exactly 360 degrees over the course of 1 second?
I have a UI Image that I want the user to click and have it rotate 360 degrees once on the z axis. I can get it to rotate through a coroutine but I'm having trouble making it stop once it is started.
...
0
votes
1answer
48 views
Zoom at a specific point using Orthographic camera
Currently I can perform Zoom which seems to be working fine but essentially what I'm really trying to do is zoom on a position offset from center as currently when I zoom then zoom is performed at the ...
1
vote
1answer
29 views
Unity3d Transfer of value from one script to another
Script 1
public class enemy : MonoBehaviour {
private Vector3 Player;
private Vector2 PlayerDirection;
public float Xdif;
public float Ydif;
private float speed;
private ...
0
votes
0answers
37 views
Purple screen when using vertex shaders
Alright, so I've tried everything I can think of. I've put in over 10 hours into this crap, but nothing seems to work (tried multiple online tutorials as well). Always purple screen.
Here is the ...
0
votes
0answers
10 views
Unity2D - How to touch and drag two gameobjects independently? Simultaneous touch control [closed]
I'm making a game which has two main characters for the player to control. But once I touch the screen to control one character.. It don't allow my other finger to touch the character. It can only ...
-3
votes
0answers
90 views
RPG Item System in Unity C# [closed]
I am trying to make an offline single player RPG game and I want to add an item system to it.
What I need as information about each item is: ID, name, dmg, price etc.
How do I handle this ...
-1
votes
1answer
32 views
Making the player Jump in like a Upper - Right manner in Unity
Ok so i'm new to unity and I am trying to make this simple ball game . Now in a situation I want the ball to jump in a diagonal manner (i.e W + D ).
Scrip that I have makes the ball jump only Up and ...
1
vote
0answers
76 views
+100
Turning On/Off Vsync no longer working when rendering to an offscreen buffer
I have this reaallly strange issue that as soon as I render to an offscreen framebuffer I am no longer able to toggle VSync while my application is running. I am using OpenTK as the opengl wrapper, ...
0
votes
0answers
21 views
LineRenderer doesn't apply material in 2D Unity5
I'm making something that draw lines with mouse on top of everything (in 2D), but the color of the line is always purple even though I assign a material to the line renderer. I could change the color ...
0
votes
1answer
52 views
Boolean change when clicking the left mouse button (not working)
I want to change a boolean when I click the left mouse button, but it doesn't work as expected. I use this method:
if (m.LeftButton == ButtonState.Released && m_Old.LeftButton == ...
0
votes
1answer
17 views
InvalidOperationException when peeking from a stack within custom editor
I've got a simple state machine for handling game states which works using GameObjects that I enable/disable in order to switch the states. Since some states can be loaded additively (such as the ...
0
votes
3answers
57 views
Gameobject not destroyed OnCollisionEnter
I have this GameObject with the tag coin I am trying to destroy when the player collides with it using this code located in a player script attached to the player
public void ...
0
votes
0answers
12 views
Making unity inspector accept classes that inherit from a base class
I have a base class that has a lot of classes inheriting from it, I want to make a script that you can drop one of these derived classes into. How do i do that?
abstract class thingy : ...
0
votes
1answer
40 views
How to address a function inside an if condition using C# in unity 3D
I am new to game development and have very limited idea of C# syntax. I was watching unity 3D tutorials of UI and thought of using ModalPanel.cs and TestModalWindow.cs
In a quiz game where 3 choices ...
3
votes
1answer
63 views
Why is quad rendered at the center (0,0) instead of top left when using orthographic projection
I have been trying to render a quad(containg a texture) using orthographic camera so that the quad can be rendered using the screen coordinates directly.
I started of by rendering just a triangle ...
3
votes
0answers
39 views
(Monogame) Camera does not travel the way it is rotated
I've implemented camera control with mouse and keyboard. My problem is that camera goes crazy when I'm using mouse and camera does not travel the way it is rotated. Could you explain me why and how to ...
0
votes
0answers
23 views
(Monogame) Camera does not travel the way it is rotated [duplicate]
I've implemented camera control with mouse and keyboard. My problem is that camera goes crazy when I'm using mouse and camera does not travel the way it is rotated. Could you explain me why and how to ...
0
votes
0answers
24 views
Rendering water with Hardware Instancing xna/MonoGame
I was wondering if rendering in XNA/MonoGame will be better using Hardware Instancing.
For example, I have my editor and when I click anywhere on my map, i'll add a plane with a water texture.
If I ...
0
votes
0answers
20 views
How i can make a spherical world with Cubiquity in Unity
I would like to make a spherical planet with cubiquity in Unity 5, how could I do it with a for (), so I could one cubic planet.
Can anybody help me?
3
votes
2answers
95 views
How can I create an “afterimage” effect like this one?
How can I make an effect like this? With a particle system?
-1
votes
0answers
27 views
2
votes
0answers
102 views
+50
Struggling with simple orthographic projection for a 2D setup
I'm trying to build a simple setup for 2D using SharpDX. Basically I want to supply my vertices in classic Cartesian coordinates: X-right, Y-up, starting with (0,0) in bottom-left corner. I've had ...
0
votes
1answer
26 views
Unity3d Resources.LoadAll<Sprite> empty array
In my resources folder structure I have myself a file, now in the unity editor this file is a Texture Type Sprite (2D and UI), now when I attempt to run this code in one of my scripts
var icons = ...
0
votes
1answer
49 views
How to rotate camera counterclockwise around player?
Holder contains camera and rotates around player
Camera looks like in diablo, titan quest, grim dawn, etc
I cant rotate camera to negative angle values
My code:
public void ChangeRotation(float ...
1
vote
1answer
36 views
Implementing getters for a singleton script in unity
Ok the title might be a bit confusing but what I want to do is make a getter that returns the class, exactly like unity does with the camera.current.
You should just be able to go class.current and ...
-1
votes
0answers
35 views
Take screenshot in Unity3D with no lags Android
I have tried each of variants: http://wiki.unity3d.com/index.php/ScreenCapture
Afterall, simple Application.Capturescreenshot(...) is the least laggy.
Please, tell me, how I can take screenshots ...
0
votes
1answer
64 views
Why does Input.GetKey(“enter”) never return true?
I want to modify an int variable on one script by having another script subtract 1 from it. But when I try to trigger this on an "enter" key press, nothing happens.
1st script:
public class ...
0
votes
1answer
37 views
Why do my obstacles float above the ground? Unity2D
I'm making an infinite runner game and I'm trying to spawn obstacles, but all of them float far above the ground instead of being at the ground level.
This is the code on summoning the bears.
...
0
votes
2answers
42 views
How to get obstacles to spawn randomly in x position in an infinite runner? 2D
I'm trying to make two obstacles that are different sized to come in a random order in one straight line where the player is going. Doesn't have to be with object pooling.
It seems that the ...
-1
votes
1answer
24 views
Unity List spawner problem ? C#
I have four spawners in my scene that spawns four enemies. My problem is when I try to add game objects to the list it works but only for one spawner.
My code
if (Score.levelNum >=2 ){
...
0
votes
0answers
47 views
Networking issue in Unity - listening port is already in use
I am trying to Network a small 2 player Unity game. This is my first go at networking, so please feel free to correct me on anything I am doing wrong. I am attempting to make a simple matchmaking ...
-1
votes
1answer
28 views
Error CS1061: doesn't contain a definition for `transfrom' and no extension method `transfrom' of type `PlayerControl' could be found [closed]
I tried finding a solution, but I couldn't find one.
I'm getting the error:
GameManager.cs(15,46): error CS1061: Type PlayerControl' does not contain a definition fortransfrom' and no extension ...
1
vote
1answer
44 views
Trying to make a 2D Spring
Still a Beginner at Unity 5 and this time I am trying to make a Spring.
The spring would act as you'd expect. Something comes in with a direction and force, so you bounce it the opposite direction of ...