How can I run StartCorutine once?

The code in my script works fine. But sometimes it does not drop after I contact the rigid body collides. When it touches another corner, it restarts the StartCoroutine. I want to run it once to get ahead of it. How can I get it? (More descriptive: I

how to disable the sound in my application with a button?

I have some mp3 audios in some scenes, and I have 1 button in my main scene and I want when user press these button, my App had no mp3 sounds. Do I Have to duplicate my App without sounds? or how? I have this but not works? public class AudioApp : Mo

How do Unity private awake update and start methods work?

How does Unity call the Awake, Update, and Start methods behind the scene? That they have no access modifier to me indicates they are private methods, and they don't use anything like new or override, so how does the Unity framework find the methods

How can I use the bluetooth controller in Unity?

I have bluetooth controller in picture. How do I use joystick and other 6 button on my android game? I can acces only escape button on controller with (Input.GetKeyDown(KeyCode.Escape)) bluetooth controllerYou could probably debug this by doing somet

Adding audioClip from Resources folder via code

How can I add and play short audioClip by name in code in Unity? I tested a lot of samples from the Internet but anyone doesn't work. AudioSource audio = gameObject.AddComponent<AudioSource>(); audio.Play((AudioClip)Resources.Load("clip1")

General close button on the C # unit

I'm writing a C# code in Unity 5.3.4. I've been trying to develop a button that will close the app be it when I test it on my computer or when I'm in Android or iOS. For android I've found this code and it's working: if (Application.platform == Runti

Access variables / functions of another script

So im trying to change a variable in another script by touching a cube. Current setup 1x Player 1x Enemy Each with their own script Enemy_Stats & Character_Stats As you can see in this little snippet it's quite a workaround to access the variable fro

Why am I unable to consolidate the score?

I am using unity. I need to consolidate the score for a game. I am unable to keep the score and post it to another scene in unity. How can this be done? #pragma strict private var playerAnswer = ""; var score : int = 0; var number : int; var num

Enter and drop the object

I'm trying new things and I'm stuck to find a way to drag and drop objects. My player is a square and he have a hand attached. Here is an example: That red thing in the arm is the "hand", when I press shift it turns green. I made the detection l

play different clips via GetKeyDown in the unit

i have the Animator with parameters of bool type. IMAGE void Update() { if (Input.GetKeyDown(KeyCode.A)) { anum.SetBool("ca", true); // anum.SetBool("ca", false); } if (Input.GetKeyDown(KeyCode.S)) { anum.SetBool("cv", true);

move a rigid body left and right

I can't seem to get my rigidbody to move left and right. The code looks fine and very similar to what everyone else has posted! The debug statement is getting called but my character is not moving left and right. Thanks for the help. public float spe

The teleportation script does not work as expected

I would like to make a gameobject in my game, which when enter trigger, then it will teleport my character to an another position (otherTeleport.transform.position), however when I use the script what I have written, my character won't teleport there

Unit | 'gameobject.renderer.material.color' in version 5.x

I want to make a portion of the gameObject(guiTexture or sprite) as transparent color like "SpriteMask" which is in asset store. https://www.assetstore.unity3d.com/kr/#!/content/27642 Let me explain in more detail. For example, there are two gam

the unit add a component (triangle) does not work

The following code is supposed to add a 3d Object for Triangle but I am recieving error Assets/Scripts/MakeTriangle.cs(6,28): error CS0120: An object reference is required to access non-static member `UnityEngine.GameObject.AddComponent(System.Type)'

Does the GPU treat invisible things?

I'm making a game in Unity 5, it's minecraft-like. For the world rendering I don't know if I should destroy cubes that I don't see or make them invisible. My idea was to destroy them, but creating them each time they become visible would take too muc

Detect Oculus HMD in the unit

public Transform OculusPlayerPrefab; public Transform DefaultPlayerPrefab; void Start() { Transform player = OVRDevice.IsHMDPresent() ? (Transform)Instantiate(OculusPlayerPrefab) : (Transform)Instantiate(DefaultPlayerPrefab); player.position = transf

Asian characters missing on Android 5.0 devices

I'm using Unity4.5.4 and NGUI 3.6, and want to support multi-languages. When I try on devices using Android 4, it is totally fine. When I install the same build on Google Nexus 7 using Android 5.0, English version is fine, but almost all the Asian ch

How to prevent RigidBody from crossing other colliders

I've got a coin (rigidbody) and walls around it with box colliders. For trial purpose I've applied the following code to the coin. void OnMouseDown() { rigidbody.AddForce(30.0f,0f,5.0f, ForceMode.Impulse); } But, sometimes the coin passes through the

can unit3 work with socket.io?

i'm trying to connect to my node.js server using socket.io client. the problem is that unity does not support it, as well a the current .Net version. i tried some 3rd party solutions like this with no luck (a lot of bugs and crushes). can anyone reco

Limiting the maximum length of a string

I need to prevent a string from exceeding a certain length and, if it does, truncate the last part of the string. I'm using GUI.TextField to get the string from the user.Wrap it with a property to handle truncation: public SomeClass { private const i

Send the Enum value in another script?

I would like to pass an enum value in a function of another script (in C#, and Unity3d), if I directly pass them through public variables, I have got an "Inconsistent accessibility" error (field type 'xx' is less accessible than field 'xx'), and