22 votes

Unity Method count exceed the limit of 64K

This answer relies heavily on Android's official documentation (the quoted parts, specifically). How to setup Multidex Support for Unity Project What is Multidex: Android application (APK) files ...
user avatar
  • 539
11 votes
Accepted

Does Unity let you code in Java?

Java is not supported by Unity. You should check out C#, however; it's a very similar language that takes a lot of influence from Java while arguably smoothing out some of the rougher edges of the ...
user avatar
  • 242
11 votes
Accepted

How do I define a required component on a Unity game object?

Applying the RequireComponent decoration to a script will ensure that the GameObject has the specified component. If the component is missing: Unity will attempt ...
user avatar
  • 3,782
9 votes
Accepted

How to keep a round body rotating without rotating it's center

Have your gameobject hierarchy like so: STAR - FACE - BODY Then rotate the Body of the star. Your face and body will be two seperate entities of course, ...
user avatar
  • 8,279
8 votes

How do C# and UnityScript differ in Unity development?

The very first question all beginning Unity developers have is C# or JS. Always go with C#. Now, right now you may be thinking, "But I don't want to learn C# and I already know a bit of JavaScript." ...
user avatar
  • 219
8 votes
Accepted

How do I get mouse x / y of the world plane in Unity?

Instead of using a collider for your terrain, you can also use a plane to perform a raycast. For example, if your grid is situated on the XZ plane, you can do something like this: ...
user avatar
  • 72.7k
8 votes
Accepted

Multiple Scripts versus single script

I'd like to separete these things due to clearity reasons but I wonder if calling different FixedUpdate() functions would imply some kind of issue. For example: is their execution ensured to be ...
user avatar
  • 2,104
6 votes

How to compress Unity apk output?

You can compress certain assets individually. After building the project, go into the log file and there will be a summary of what assets were packaged with the apk, and their sizes. (On windows, ...
user avatar
6 votes
Accepted

Change unity physics engine speed

You can use Time.TimeScale for slow motion effect.
user avatar
6 votes
Accepted

How to avoid Walls in A*

Add a restriction to the tiles your A* algorithm is able to consider and this will eliminate the undesired diagonals. You wish to remove prevent two things from occurring, the first is you do not ...
user avatar
6 votes
Accepted

Update and FixedUpdate together

Update Order When you’re keeping track of game logic and interactions, animations, camera positions, etc., there are a few different events you can use. The common pattern is to perform most tasks ...
user avatar
  • 539
5 votes

How to increase the game "level" after certain amount of objects spawned?

Well the totalShots value stays at 10 until you increase it, so totalShots % 10 == 0 will continue to be true until you ...
user avatar
  • 2,056
5 votes
Accepted

Prefab random rotation in editor

Found it! Attribute [ExecuteInEditMode] does what I want ...
user avatar
  • 308
5 votes
Accepted

2D Boat controlling physics

The simplest, modestly realistic, model I can think of would be parameterized by the following: Mz The Turning Moment of the ship about the steering (ie Z or yaw) axis; L/2 The distance of the ...
user avatar
5 votes
Accepted

How to change the gravity with a click

...
user avatar
5 votes
Accepted

How does Color.Lerp works?

Color.Lerp in Unity works just as any lerp implementation, which works like this: ...
user avatar
  • 3,182
5 votes

How to move a object to a target point like sine wave in 2D world

I'm going to explain as much as I can to avoid more questions. Let's begin from the simple linear motion. It's something like: ...
user avatar
  • 1,404
5 votes
Accepted

Minigame inside game in Unity

You can load a scene without destroying anything in the current scene by using the method SceneManager.LoadScene with the ...
user avatar
  • 112k
5 votes

Converting UnityScript code to C#: What is the alternative for .ToBuiltin?

In Unity's JavaScript implementation (sometimes called UnityScript), there are two types of array: JavaScript-style arrays, which have no particular type or length, and "Builtin" (native ....
user avatar
  • 114k
5 votes
Accepted

C# invoke stops unity

The label and goto in your FixedUpdate method is an infinite loop equivilent to: ...
user avatar
5 votes
Accepted

Random Range Without Duplicates

Common approach Shuffle your array. A simple Fisher–Yates shuffle will do. The result is that you will have your array of GameObject in a random order. When ...
user avatar
  • 18.5k
4 votes
Accepted

Retrieve the original prefab from a game object

Simple Answer Use a class to load the original prefab from Resources.Load(string prefabPath, typeof(GameObject)); Store this returned prefab into a resource pool ...
user avatar
4 votes

Does Unity let you code in Java?

Unity supports only C#, JavaScript and BooScript for scripting. However as Philipp mentioned,...
user avatar
  • 603
4 votes
Accepted

Unity's StartCoroutine funtionality inside a .NET Library and outside a MonoBehaviour

Yes, it is possible to do using iterators. I've put some pseudo C# code here to give you an idea. You use yield return to return something from an iterator, which ...
user avatar
  • 3,567
4 votes
Accepted

How can I merge multiple sprite into one sprite or texture using Unity3d?

You can use a RTT (render-to-texture) and a custom camera to one-shot render to it to merge all the layers using the GPU. You can then save and use the resulting texture. http://docs.unity3d.com/...
user avatar
4 votes
Accepted

Checking if object passed between two other objects

You can use vectors, they're quite handy in fact. Oddly enough you'll need to use 3D vectors to accomplish this 2D task, but it's all rather straight forward. First let's look at how to figure out if ...
user avatar
4 votes

Insert 3d text to the front face of a cube GameObject

I think understand this question well enough to answer it and a year old (old questions deserve some love too). Simply adding the TextMesh component to the cube is insufficient, as the text mesh has ...
user avatar
4 votes
Accepted

Multiple enemy collidiers

First its good to note the difference between Colliders and Triggers Colliders - generally are intended to represent physics interactions, so objects "colliding with them" should not pass through one ...
user avatar
  • 548
4 votes

How to apply a script to multiple Objects in Unity?

Here are the steps for applying scripts to multiple objects. Step 1. Select all your objects from Hierarchy panel. Step 2. Then from ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible