Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [unity]

Unity is a cross-platform game creation system that focuses on easy art pipeline process. It consists of a game engine and an integrated development environment. The game engine's scripting is built on Mono.

10
votes
1answer
2k views

Confusion about Sprite Size in World Space (Unity)

I have a Sprite with 1080x1920 resolution. And I set the Game View Resolution also to 1080x1920. What I was thinking is that the sprite (1080x1920) should fit correctly within the Camera View. But ...
10
votes
3answers
22k views

Most efficient way to convert Vector3 to Vector2

What is the most efficient and fastest way to convert a Vector3 to a Vector2? Casting: Vector2 vector2 = (Vector2)vector3; Initializing a new Vector2: ...
10
votes
2answers
3k views

Is white the best base color to start with when planning to shade sprites within Unity?

I'm looking into prototyping a game in Unity which will consist of solid square sprites / tiles. I figure I can represent different types of objects with different colors for each of the tiles in the ...
10
votes
2answers
19k views

What's the difference between Update and FixedUpdate in Unity, and should I bother?

I was told to use Update() for graphics and FixedUpdate() for physics, but sometimes my inputs won't register when I use ...
10
votes
1answer
1k views

Finding the correct speed for AI to turn to reach goal

I have a ship that travels at max speed maxSpeed and can turn rotationSpeed degrees per second. The ship always moves in the ...
10
votes
2answers
19k views

Shader that “cuts” hole through all geometry

How can I create a shader that "cuts" through all geometry, only rendering the clearing background in Unity? An example: That's a prism in a huge white box-shaped room. The surface of the prism is ...
10
votes
3answers
2k views

How can I make natural rain drops on screen?

I'm trying to make rain effect drop with metaballs and trail on screen.I find a clue in shadertoy but I didn't understand how implemented: https://www.shadertoy.com/view/ltffzl unfortunately it have ...
10
votes
3answers
2k views

How to handle RTS Click-And-Move in 3D Space?

How can I handle the click-and-move in a complete 3D space? It is easy to handle on a 2D plane by a simple raycast, but this is not the case in 3D since there is no end-plane for a raycast to get an ...
10
votes
2answers
8k views

Unity UI square that fills width OR height

I'm trying to create a board with this requirements: It SHALL be square. It SHALL fit available width OR height. It SHALL be centered in the canvas. It MAY be wrapped into as many additional ...
10
votes
2answers
4k views

problem with git on a unity project

I tried to version control my project folder with git. When it came to pull the project from the repository, though, something went wrong: apparently scripts are missing and the prefabs and kind of ...
10
votes
1answer
541 views

Getting a 2D “pixel” cloud to follow a mouse

I'm working on a 2D game trying to get a "cloud" of a few hundred tiny cubes or discs to follow my mouse cursor without overlapping each other. However, using the physics engine introduces ...
10
votes
2answers
16k views

Difference between unity scripting backend IL2CPP and Mono2x

IL2CPP is a Unity-developed scripting back-end which you can use as an alternative to Mono when building projects for some platforms.Note - IL2CPP is only available when building for the following ...
10
votes
2answers
981 views

Conditional Variables in Scriptable Objects

While using ScriptableObjects, how can I make some variables conditional? Example Code: ...
10
votes
4answers
12k views

How to make Line Renderer lines stay flat?

I've noticed that as I add more vertexes to a Line Renderer line the line twists and stops being a smooth line. .GIF Here: http://i.imgur.com/hRAhCXM.gif All lines are on the same z level, even if ...
10
votes
1answer
6k views

Why doesn't Unity's OnCollisionEnter give me surface normals, and what's the most reliable way to get them?

Unity's on collision event gives you a Collision object that gives you some information about the collision that happened (including a list of ContactPoints with hit normals). But what you don't get ...
10
votes
1answer
1k views

Determining how loud an AudioClip is

I have some code that uses GetSpectrumData from an AudioSource playing a song to create a level layout for the player to play. I want to add a functionality where ...
10
votes
2answers
5k views

Accessing DualShock 4 motion sensor in Windows (ideally Unity)

I'm trying to use a DualShock 4's IMU as a motion controller in Unity, under Windows 7. So far I've tried: DS4Windows (1.5.11): reads motion sensor data, but does not expose them to Unity as axes ...
10
votes
2answers
2k views

Prototype experience: Unity3D vs UDK [closed]

Has anyone yet prototyped a game in both Unity3D and UDK? If so, which features made prototyping the game easier or more difficult in each toolkit? Was one prototype demonstrably better than the ...
10
votes
2answers
5k views

How do I flatten terrain under a game object?

I've got a script that makes a terrain object and paints it with textures, but I'm having an issue. When I attempt to place game objects (such as the simple water object that unity provides), I use a ...
10
votes
1answer
2k views

Creating a Robust Item System

My aim is to create a modular / as generic as possible item system which could handle things like: Upgradeable Items (+6 Katana) Stat Modifiers(+15 dexterity) Item Modifiers(%X chance to do Y damage, ...
10
votes
4answers
1k views

Calculating missile trajectory around orbits before shooting

I'm building a game with Unity3D. It's a Gravity Wars clone. Both player and AI turrets shoot missiles at each other (giving an Angle and a Power variables), trying not to crash missiles on planets. ...
10
votes
2answers
4k views

Unity Occlusion Portals: What and How?

(Here I eat my words on Meta about posting Unity questions on Unity Answers... since that site is less responsive than this one.) Unity provides cell-based Occlusion Culling (via Umbra, I believe). ...
10
votes
1answer
7k views

Can you embed a Unity3d mobile project into an existing native mobile app?

I am creating an application for both Android and iPhone that will have a few mini games in it. I would like to create the non game section in native Android and iPhone. My question is, is it possible ...
10
votes
2answers
1k views

How to project a foam trail on dynamically changing mesh

I am trying to create water, and right now I got it through dynamically generating waves on a mesh. But now I want to make my boat manipulate these waves, and cause a Kelvin Wake on top of this. ...
10
votes
1answer
5k views

Inline sprites in Unity's text?

How can I use different materials when using the tag for Unity's rich text syntax? I want to be able to have sprites that are inline with my text without having to create custom fonts. Here's what I ...
9
votes
4answers
16k views

Why doesn't my C#6 code compile in Unity?

Why can't Unity work with C# 6 code? It always gives me compiler errors. Here are some code examples: ...
9
votes
7answers
22k views

Why do my point lights disappear when another nearby light is above 1.85 range?

I'm making a game with a dungeon setting in Unity 3D. Many torches line the walls. I'm using a point light over each torch to simulate the flame. However, when two torches are across from each other, ...
9
votes
4answers
1k views

Should Unity lifecycle methods be annotated with the UsedImplicitly attribute?

Does annotating Unity lifecycle methods with the UsedImplicitly attribute improve the readability of your code? For example: ...
9
votes
2answers
2k views

How to make a field visible (attachable) in the inspector but inaccessible through code (private-like)?

Let's say I have a variable named button of type Button which is of course ...
9
votes
2answers
5k views

Why do Unity layer masks need to use bit shifting?

I've finally figured out why my layer masks for my ground collision code weren't working. I was using NameToLayer() to get the layer I needed, but layer masks use ...
9
votes
5answers
18k views

Unity: how to detect collision occuring on child object, from a parent script?

I've an enemy, with this structure Enemy Body Head Arm Left Arm right And so on. I also have a collider for each part of the body. In my "Enemy" object I've attached a script and in that script ...
9
votes
1answer
3k views

Unity - Order in Z layer for objects

Sorry if the title isn't exactly what my question is, I don't really know how to describe it. I have an image for my city floor and an image (same size) for all the walls or trees that the player is ...
9
votes
2answers
68k views

How to use Input.GetAxis(“Mouse X/Y”) to rotate the camera?

I want to make a first person camera that rotates with the mouse. I looked at the Input.GetAxis Scripting API page and found a sample code, which I have included at the bottom of my post. Upon trying ...
9
votes
1answer
67k views

Change the sprite of a Object in Unity

Inside the script code of the the hero(object) I want add the possibility to change its sprite. So the player hits the space button and the sprite changes into the other sprite already added to the ...
9
votes
2answers
3k views

Coroutines in series

How would i go about stacking up a series of Coroutine calls that should be executed one after the other? I have tried getting a flashing color effect looping a series of color lerps in a coroutine ...
9
votes
1answer
16k views

ResolutionException: Cannot find candidate artifact for com.google.android.gms:play-services-games:8.1+

Getting this error: ResolutionException: Cannot find candidate artifact for com.google.android.gms:play-services-games:8.1+ Google.JarResolver.PlayServicesSupport.DependOn (System.String group, ...
9
votes
1answer
719 views

How can I fix zig-zagging UV mapping artifacts on a generated mesh that tapers?

I am creating a procedural mesh based on a curve and the size of the mesh gets smaller throughout the curve as you see below. And the problem is UV gets zig-zagged as the size changes (it works ...
9
votes
5answers
7k views

Non-destructive way to edit alpha channel in Photoshop/Gimp image

Looking to make textures for Unity3d, and I'm stuck at what seems to be a simple stage. My goal is to create an RGBA image, with color information for every pixel, and a separate alpha channel. These ...
9
votes
2answers
483 views

How to avoid spaghetti in the animator?

I am working with animations in Unity and so far I have made only four (Up Down Left and Right) and my animation window looks following... Problem is that if I was moving Up I want hero to stay ...
9
votes
2answers
565 views

Why doesn't light continuous on my model?

I created a basic textured cube model with Blender to practice modeling, and then I imported it into Unity. After I put up some lighting it looks pretty ugly. The light is not continuous on a row of ...
9
votes
3answers
4k views

NullReferenceException in Unity

Since many users are facing the NullReferenceException: Object reference not set to an instance of an object error in Unity, I thought that it would be a good idea ...
9
votes
1answer
11k views

Why does Unity let you install iOS Build Support on Windows?

When installing Unity on a Windows machine, you are allowed to select "iOS Build Support" as one of the components to install. However, it is not possible to make an iOS build from Windows. Why is ...
9
votes
3answers
546 views

Slerping rotation mirrors

I rotate my game character to watch at the target using the following code: ...
9
votes
2answers
29k views

Resolution problems when porting a Unity game to Android

So, I'm porting a game to the Android for the first time in Unity3D. And I've run in to a few problems along the way. My current problem is the resolution doesn't seem to be right, it cuts off the ...
9
votes
1answer
4k views

How can I record from a second in-game camera and later export it to a video file?

I'm making a PC Horror game in Unity, and I want to have a camera recording simulation in-game - so you can leave a creepy location anytime, and you will have a tape with what you recorded on camera ...
9
votes
2answers
5k views

How well does Unity 3d work for both Android and iPhone?

First off this question might be a bit broad so I apologize if it is. I am really just looking for peoples experiences and personal knowledge on the subject. I am looking to create a game for both ...
9
votes
1answer
8k views

How to create high quality and fast portal effect?

EDIT: So I've gotten the portal visual effect working with no performance hit, and I've got the physics set up of objects with rigidbodies moving through portals seamlessly, and objects with character ...
9
votes
5answers
28k views

How to create a new GameObject, without adding it to the scene?

I'm creating what is essentially my own prefab system. Game objects are defined by a human readable data file. I'd like to create an empty GameObject, load it with the components defined in the data ...
9
votes
1answer
1k views

Building an Octree for terrain generation

I've previously implemented marching cubes/tetrahedra to render an IsoSurface. It worked (YouTube), but the performance was dire as I never got around to implementing variable Level of Detail based on ...
9
votes
1answer
784 views

How do I manually draw a part of a sprite sheet?

I'm working in Unity, and I'm finding that the animator isn't working for what I'm trying to do, in my 2D game. I want to build a specific animation, using sprite sheets, and be able to reuse the ...