FAQ Database Discussion Community


Unity3D: Adding charged force in relation to position

c#,unity3d,position,transform
I am trying to make a game which "kind of" simulates the shooting of the "worms" game. The player can choose the position (circular) of an object and then, the force that is applied to the object should move in the direction its pointing towards. I tried using the AddForce(transform.right)...

SWF works locally but not loaded from server

mod-rewrite,unity3d,swf,swfobject
Here is the deal. I have SWF build with Unity and embedded into HTML page with swfobject. It works perfectly well when I load page locally (zip), but it always says "Movie not loaded" when I try to load page. from server I have already inspect similar embedded movies (this...

How do I detect if a sprite is touching another sprite

c#,unity3d
How do I determine if a sprite (Sprite1) if on top of (Sprite2) I need this to switch levels when you touch another sprite with your sprite. I tried: void OnCollisionEnter2D(Collision2D other) { //code to run } But this made it so that everything it touched ran the code. :(...

How do I convert point to local coordinates?

c#,user-interface,button,unity3d
when a user taps a button I want the tap to be ignored if a transparent pixel is hit and the button beneath it should receive the tap instead. I can do this sort of behaviour in objective c within a few minutes, however, trying to do it in Unity...

Unity2D C# - Can't destroy an Instantiated object

c#,unity3d
public class playerAttack : MonoBehaviour { public bool attacking = false; public Transform Player; public Transform swordObject_prefab; Animator anim; GameObject clone = null; // Use this for initialization void Start () { anim = GetComponent<Animator> (); } // Update is called once per frame void Update () { if (!attacking...

Unity3D Play sound from particle

audio,unity3d,collision,particles
I am trying to play a sound when a particle collides with a wall. Right now, it just plays the sound from the parent object, which is the player. However, I want the sound to play from the particle. Which means when a particle is far to the left, you...

unity add component (triangle) not working

c#,unity3d
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)' using UnityEngine; using System.Collections; public class MakeTriangle : MonoBehaviour { void Start(){ GameObject.AddComponent<MeshFilter>(); GameObject.AddComponent<MeshRenderer>(); Mesh mesh = GetComponent<MeshFilter> ().mesh; mesh.Clear();...

Convert a large int to a float between 0.0f and 1.0f

math,unity3d,numbers
I'm working on a project where I have a pane that goes from 0 to 500 on the x and z, but I need to convert that coordinate (from 0 to 500) to a float in the range of 0.0 to 1.0 in because it is required from some of...

Converting from Pixel Coordinates to UI Coordinates in Unity

user-interface,unity3d
Does anyone know how to convert from Pixel Coordinates to UI Coordinates and vice-versa in Unity? Let's say for example I want to click somewhere on the screen with the mouse, and a UI Image to be at that click position. If I do this won't work: Image img =...

Unity3D: Moving a child to orbit a parent

c#,unity3d,position,transform
I have made a game where I make two spheres, one child sphere and one parent sphere. The parent sphere is bigger than the child sphere, and I am trying to make the child move around the parent sphere. In the following code, the child sphere moves in a circle....

Git will not push up everything in assets (Unity 5)

git,github,unity3d
I've just started a unity project with one of my friends for some fun and decided to use git to collaborate. I created the project on my computer and pushed it. Everything seems to be working except for nothing from my assets folder (but the scene) is getting pushed to...

Reserve Ammo Formula

unity3d,fps
Here's my problem. I'm working on an FPS with a Counter-Strike/TF2esque ammunition system. My problem is, my current formula gives some weird, glitchy results when one reloads from a 1/1 ammo state (as in one chambered, one reserve). My system will produce an additional round from thin air. This is...

how to add Scoring to unity3D 2d top down car game?

unity3d,2d,car,topdown
I'm making 2D top down car game. as for now car game working with if player car hit enemy car game is over. I used for it adding tag to Enemy car and if player car collision detect enemy car with tag the finish the game. My question is: How...

I'm trying to reduce the Length of this Code

c#,unity3d
I wrote some code today. I can't figure out how to reduce the length of this code, although it seems repetitive, every part is different. try { totalVerts.Add(verts[i]); if (verts[i].x > maxXvert) { maxXvert = verts[i].x; } if (verts[i].x < minXvert) { minXvert = verts[i].x; } if (verts[i].y > maxYvert)...

Instantiate GameObject at Random time is not working

unity3d
I want the enemy to spawn at random time between 1-5 seconds but when I applied the script inside the game , the game is spammed with enemies and it continuously nonstop spawning enemies ! using UnityEngine; using System.Collections; public class Game_Control : MonoBehaviour { private bool Spawn1=true; public GameObject...

Using Project Tango Unity example projects

android,unity3d,google-project-tango
I have tried to use the Project Tango unity examples found here; https://github.com/googlesamples/tango-examples-unity with no success. I have never used Unity before, and have successfully completed the Codelab: Motion Tracking example fromt he developer resources: https://developers.google.com/project-tango/apis/unity/unity-codelab-motion-tracking. I downloaded the example files mentioned at the top, open one of the projects...

Loading MP3 files at runtime in unity

c#,unity3d
I'm trying to load an mp3 file at runtime using the WWW class that is provided in Unity. I don't get any errors, but I'm unable to play the music after the song has been processed. I have looked everywhere and cannot find anything to help me. Here is the...

Scoring scale object

unity3d
I started working with Unity platform just a few days ago. I want to create and object like this one: (http://www.bankingsense.com/wp-content/uploads/2014/09/credit-score-ratings.png) where the user will choose the appropriate answer. Each option will generate a different score that should be stored for later use. Can anyone give me some tips ad...

Android - Unity3D freeze in splash screen on some phones

android,unity3d,screen,freeze,splash
I have a problem with Unity3D. I created a game with Unity 4.6.2f1. My problem is, game crashes after splash screen(Like trying to open itself constantly). The weird part is, game works on my phones and my tablets perfectly. I have Nexus 5(With Android 5.1.1) , Iocean X7S(With Android 4.2.2)...

Integrating Unity3d into iOS UITabbarController / UINavigationController

ios,objective-c,xcode,unity3d
I've manage to compile my iOS project with Unity in it. Tested and the unity project runs in my iOS project if it's the first view. However I'm trying to initialize it in another subview. Initially my application AppDelegate will handle the self.window.rootViewController It seems like I have to pass...

How to check button clicked in new UI button of unity 5.0

button,unity3d
I added the new UI buttons of unity 5.0 in place of the old GUI texture buttons in these buttons how to i check when the button has been pressed and released and how to make the Onclick event keep repeating itself...

ant jar error: Execute failed: java.io.IOException: Cannot run program…${aapt}": error=2, No such file or directory

java,android,osx,unity3d,jar
I'm trying to compile a simple Java library for Unity, and after running ant jar, I get the following message: /Applications/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:649: The following error occurred while executing this line: /Applications/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:694: Execute failed: java.io.IOException: Cannot run program "/Users/****/UnityProjects/****/JavaTestPlugin/${aapt}": error=2, No such file or directory This is strange, because I've compiled this...

Why is my Rigidbody != null immediately after seeing that it is null?

c#,generics,unity3d,null
I am checking to see if "My Game Object" has a Rigidbody. It does not. But the conditional for the null check on Rigidbody fails, despite having just been proven null. Why is this happening? How can I make my condition block run? using UnityEngine; using System.Collections; public class NullChecker...

Our iOS developer has developed a game in Unity3D. How do we export it for Android?

unity3d
Our iOS developer has developed a game in Unity3D. How do we export it for Android? I did a quick check on the internet and it says there "one click export for Android". Is this really the case? Are there ways it might have been developed that will make it...

Unity - Gui Button issues (Android)

c#,android,button,unity3d
I'm fairly new to Unity and I am creating my first game for android as a bit of a play around. I have this game where you can use a boost by pressing a button. The player can pick up multiple boosts along the way. At the minute, I am...

Csproj file in unity changes everytime i reload the project

c#,unity3d,msbuildcommunitytasks
I want to change the 'csproj' file of my unity project in order to be able to access a specific library as this answer sugests. I am manually editing the file but every time i reload the project, the 'csproj' file returns to it's initial state. Is this a common...

Shooting a ball (With gravity)

c#,unity3d
I am currently having trouble shooting a ball and adding velocity to it. The idea is that the longer you hold down "SPACE" the longer the ball will travel. What I have so far is this for the player control: public class PlayerControl : MonoBehaviour { public float speed =...

screen fills with object texture after creating user defined target(vuforia 4 unity)

unity3d,vuforia,ar
I created this small demo where I am creating a user defined target, the model is generating fine on pc after creating the target , it works fine when I test it on pc(using webcam,image is attached) but when I test it on my phone(motog 2),after creating the user defined...

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

unity3d,shader,crop,mask,renderer
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 gameObject in the scene. One is the background of the scene and the other one is just...

How to scroll to a specific element in ScrollRect with Unity UI?

user-interface,unity3d,unity3d-gui
I built a registration form for a mobile game using Unity 5.1. To do that, I use Unity UI components: ScrollRect + Autolayout (Vertical layout) + Text (labels) + Input Field. This part works fine. But, when keyboard is opened, the selected field is under keyboard. Is there a way...

Best way to get variable from another script

c#,class,unity3d
I'm working on a 2D game and I have many c# script. Some variable like Speed influence to a lot of gameObject's and script. I want to all of these script's read Speed variable from just one script and I do this with property and it worked very well. But...

Unity: GameObject.FindGameObjectWithTag isn't working and I don't know why

unity3d
I have a enemy AI script and a small part of the code isn't working. It's supposed to search for a game object with the Player tag when the target no longer exists. So, when the player collects a power up and a new player prefab spawns in its place...

Unity3D Bullet Tracers

unity3d,unityscript,raycasting
I'm currently working on implementing the elusive bullet tracer to my FPS. It isn't going so well. a. The tracers align themselves off of the barrel of the Raycast area b. They all aim themselves in the same direction, no matter where I point my cursor This is the formula...

Constant animation hapenning when moving

c#,unity3d
I have the following code, but i'm having some problems. Every time update is called, the character move to the point i give him to. But i just give him a point when i click with the mouse on the ground, the problem starts when i try to make it...

Create array/list of many objects(initially unknown amount) by tag

c#,arrays,list,unity3d,gameobject
I'm currently working on a radar system for my space game, and I am trying to work out how to add gameobjects, by tag, to either a list or array that can then be used in other methods. I can't do this manually because I will be procedurally generating each...

Unity procedural TileMap generation without creating gameobject per tile

unity3d
I've been searching all over the internet to find a efficient way to create procedural tilemap without creating a gameobject per each tile. There is none, or simply i couldn't find it, because i really don't know how to make a search for it. All the TileMap tutorials i found...

Input disabled after moving object in editor while in “play mode”

unity3d,unity3d-editor
This is my first question here, i couldn't find an answer online for my problem. Here it is: I made a simple script to print some debug info about objects when i press a key. It works as expected unless i first move any of the objects in the scene...

Using Unity to plot 3d geometry with sin & cos

c#,unity3d
I'm interested in using Unity for more than just games. Things like data visualization, installation work, interfacing with sensors, etc. I came across a book full of formulas for 3d geometric patterns using sin and cos. Can anyone tell me how I might translate these formulas into actual visible 3d...

How do I Mute The Audio In Unity 3D?

c#,audio,unity3d,mute
with script this. what is wrong in script this ? audio.mute = ToggleButton.isSpeakerOff; sorry bad english,fast answer please correct my script please...

Turning an avatar into a 3rd person character

animation,unity3d
I just learned how easy it is to simply drag a 3rd person character controller prefab (from Unity's standard assets package) and drop it into the hierarchy. Using the WSAD and Space keys feels pretty natural, so I wondered if I could apply the same character controller to a customized...

Crash EXC_CRASH (SIGABRT) unity + vuforia + ios

ios,unity3d,vuforia,ios8.3
This is my first post.Does anyone know what error of this code? I use unity 4.6.5 with vuforia plugin 4 and xcode 6.2. Apple center reject my app because iPhone 4S running iOS 8.3-iPhone 5C running iOS 8.3- iPhone 5S running iOS 8.3- iPhone 6 running iOS 8.3-iPhone 6 Plus...

When building to mobile the size of fonts reduce and became very small

c#,user-interface,unity3d,uibutton,unityscript
Like I said in the title when i built to mobile the letter became too small. I think it is because phone has more pixel for his little screen. Well I tried to fix text by simply making text to images in photoshop. But how can I make InputFields text...

Controlling a player using touch input on the mobile device

android,ios,mobile,unity3d,touch
I am new to Unity, and was following the tutorials of roll a ball. I was to create it for both mobile and desktop and it is working but the only problem I have is that I am unable to create touch keys arrows(left,right,up,down) to control the player on the...

IOS developer from windows [duplicate]

ios,iphone,unity3d
This question already has an answer here: How can I develop for iPhone using a Windows development machine? 41 answers Do I have to own a Mac to upload games made by unity to the app store? How to test apps on IOS? Because in android its so easy...

converting string to vector in Unity

vector,unity3d,unityscript
I am trying to convert an array of strings in unityscript with values holding values like: "Vector3(5, 3, 8)" into an array of vectors, but Unity will not take these strings as is. Anyone have any ideas?...

AdColony's OnVideoFinished not call in Android

c#,android,unity3d,adcolony
I have a problem with AdColony-UnitySDK. When AdColony's video is finish playing, OnVideoFinished() method don't be called. In this case, the following sources work well in iOS. And also, the server receive the success callback both device. So, only Android device that is not work. Here is the source code,...

Unity3d strange Collider behaviour

unity3d
I found something I can't understand. I'm only a beginner, so I thought I could use the CarController Scripts of the Car Demo for making a little driving game with different models. the Car demo I wonder why the colliders are sub-objects and the RigidBody has "Gravity-Enabled" without falling apart....

Make two physics objects not collide but do detect collisions in Unity

unity3d,2d,physics
I have a Unity project in which there is a 2D game world that consists of static colliders to make the geometry solid to the characters that inhabit it. The player is a dynamic collider (with a non-kinematic rigidbody). There's also an enemy character that is also a dynamic collider....

How to draw each a vertex of a mesh as a circle

ios,unity3d,shader,mesh,particle
How to draw each a vertex of a mesh as a circle?

Unity3D: Adding force based on direction an object is facing

c#,unity3d,transform
I am trying to make a "worms"-like game where the player can choose the position of an object (the player can move the object around 180 degrees) , and then the force would be added to the direction the object is facing. I tried using transform.right and transform.forward, but the...

Unity: Android and iOS Push Notifications

android,ios,unity3d,push-notification,android-notifications
I'm working on a mobile game with Unity and going to use push notifications. I found NotificationServices class that for iOS only. But I didn't find any server-side code examples for that class. I'm asking for any nice examples or solutions providing server and client-side code (Android client & backend...

Iterating through multiple levels of Child Objects

c#,unity3d,iterator
I have this block of code. And I need to iterate through every child object, but child objects could have more children within them. The Awake() method is called when the program is first ran. So, I'm asking how to build an iterator that will check if there are children...

Why i can't see Fixed Angle option in Rigidbody2D in the new Unity5?

unity3d
That's it, i can't see the option in the inspector. I saw it in the old Unity4 but i can't do it now in unity 5. Also, it is in the 5.10 version. Please help me, i'm newbie haha.

Mesh tilemap and scrolling

c#,unity3d,game-engine,mesh,tile
I'm working on a top-down game where the player can move up, down, left, or right. I've come across tilemaps but since using Unity, I'm seeing the idea of using Meshes. I don't quite understand how this works. Is it one mesh (two triangles) per tile? If I want to...

Unity WebPlayer “Failed to initialize player's 3D settings”?

web,unity3d,3d,augmented-reality,unity-web-player
I am trying to execute one of Daqri's AR demos, but I keep getting "Failed to initialize player's 3D settings" ...error every time I try to run the demo (Which is essentially a webpage). I am using unity 5.0.0f4 and even 4.5.3f3 (As a tried to implement a fix that...

Unity 3D Text becomes Word Cubes

android,unity3d,vuforia
As the image shows, my 3D Text keeps disappearing from my scene when I click Play, and then when I zoom in, this is what I see. When I exit the Play scene, it stays like that till I Ctrl+S and Save on which is returns to its proper text...

What is this programming method called? And is it bad?

c#,unity3d,modular
Lately in my Unity projects, I have discovered that to create a more modular application it helps to have a static List in a class that contains references to all or some of the objects created so that they may be accessed easily from other parts of the program. An...

Retrieving data from a database in another thread(Unity3D)

c#,multithreading,unity3d
I currently have a code which retrieves data from a database and visualizes it in unity3D. However, everytime it retrieves data in the FixedUpdate() function, it spikes dramatically every 1 second. I'm thinking about using threading to do this but i'm not sure what i'm doing wrong. This is the...

Unity 5 Audio Volume Slider (Solved)

c#,audio,unity3d
I am trying to create an slider that I can use for volume control in Unity 5 but the volume will not change. My Game Objects are called MainMusicPlayer for the audio source and Volume Slider for the slider I am going to post the whole script as it would...

how can I create a button with texturepackerimporter texture?

unity3d,uibutton,texturepacker
I can drag the prefabs texture to scene. But I don't know how to create a ui button use this texture.

I cant get custom GUIskin to work

c#,unity3d
I have this code using UnityEngine; using System.Collections; public class InfoInput : MonoBehaviour { public string charname = "Name"; public string usrname = "User Name"; public string charrace = "Race"; public string charclass = "Class"; public string charalli = "LG"; public string next = "Next"; void OnGUI() { int x...

Changing the length of a line renderer using DOTween

unity3d,tween
I am trying to change the length of my line renderer over time using DOTween. LineRenderer myLineRenderer = GetComponent<LineRenderer>(); myLineRenderer.SetPosition(1, new Vector3(x, 0, 0)); This code snippet changes the position of myLineRenderer to x. How can I use DOTween to set the position gradually to x over 1 second?...

Why am I getting the following error when compiling this assembly?

c#,unity3d,mono,.net-assembly
I'm attempting to use the following command line command to compile an assembly of the code from my project: C:/"Program Files"/Unity/Editor/Data/Mono/bin/gmcs -target:library -out:C:/Users/Austin/Desktop/PixelExpanse.dll -recurse:C:/Users/Austin/Desktop/Projects/Repos/trunk/PixelExpanse/SpaceColonyRefactor/Assets/Source/*.cs -d:RUNTIME -r:C:/"Program Files"/Unity/Editor/Data/Managed/UnityEngine.dll As you can see, I am, I believe, correctly referencing the UnityEngine.dll. The code that would be compiled contains references to UnityEngine.UI...

Manual slide-in animation using delta time

c#,animation,unity3d
I'm creating a simple slide-in animation for my game. The box is shown at the bottom with character dialog. The animation is supposed to look as follows: A square slides in from the left, then waits a bit, then expands to its full width. The box is made using Unity's...

var keyword vs actual type? [duplicate]

c#,unity3d
This question already has an answer here: Use of var keyword in C# 86 answers I'm using vim + omnisharp/syntastic for some unity3d development in C#. When I declare a variable using the actual type, for instance string[] myArray = new string[5]; I get a warning message telling me...

Prevent Construction of object using new()

c#,unity3d,new-operator
In the Unity game engine, all classes deriving from a MonoBehaviour class cannot be constructed with the new() operator, despite their default constructors being public. Doing so returns a warning in the Unity log and the object is not instantiated, leaving the reference null. I'm curious how they managed to...

Unity OnMouseEnter not working

c#,unity3d
I'll post the link to the project here I seem to be unable to figure out how to make my OnMouseEnter function work (it has worked in a previous project but won't now). Google Drive - Space Cadets using UnityEngine; using System.Collections; public class MouseHover : MonoBehaviour { void Start(){...

EditorGUILayout.Popup option is not changing

unity3d,unity3d-gui,unity3d-editor
using this simple code I'm showing a dropdown int selected = 0; ///* string[] options = new string[] { "Start With", "End With", "Contains", }; //criteria = EditorGUILayout.Popup("Search Criteria", 2, options); //*/ criteria = EditorGUILayout.Popup("Awesome Drop down:", selected, options, EditorStyles.popup); it showing dropdown with option perfectly but the problem is...

Unity3D 5 packages conflict

unity3d,google-play,package,admob
I have Unity 5.0.2f1. Firstly, I've successfully added GooglePlayGamesPlugin-0.9.20.unitypackage to my project. Then, I've tried to import GoogleMobileAds.unitypackage, but I got these errors: Error importing folder (The pathName assets/plugins is already mapped to fce8a713f1e5a4cc4b9973d1ef630f31. But the meta data wants it to be mapped to cbde64d36fd994c458fffca9e931b232) Error importing folder (The pathName...

How expensive is creating class instance? (performance considerations) [closed]

c#,unity3d
In C#, how expensive it is to create new class instance? I'm speaking in context of using C# in unity3d. Meaning that stuff continuously gets called many times per second. In C++, generally speaking (while making games) you may want to reuse anything you created with new/smart pointers, you would...

Unity3d get Mouse Input Axis

c#,unity3d,mouse
I want to rotate a GameObject through mouse movement between -20° and +20°. I know that there's a possibility to grab the smoothed Input through Input.GetAxis("Horizontal"); and Input.GetAxis("Vertical"); which returns float values between -1 and 1 It would be nice if there would exist something like Input.GetMouseAxis("Horizontal"); or Input.GetMouseAxis("Horizontal");. But...

Unity: Prefab parenting in code

unity3d,gameobject
Let's say I want multiple prefab object called childTile, it parenting another single prefab object called parentTile. So whenever the parentTile rotates, childTiles will be rotated around parentTile. Basically this is what I wrote: public GameObject childPrefab; public GameObject parentPrefab; void Update() { for(int i = 0; i < 10;...

Unity3d - Input.GetKey returns true more than once

c#,unity3d,event-handling,keyboard
I want to move my object on scene using keyboard inputs. To do this work, I create an empty game object and attach a .cs file to it. Code of this .cs file is below : void Update() { if (Input.GetKey ("up") ) { Debug.Log("up"); } else if (Input.GetKey ("down")...

Delete animation of a certain bone for a number of frames Unity3d

unity3d,unityscript
I have an animation of a Mecanim. I wonder how I can delete the animation of only the right-hand for the next couple of frames once I press a certain key in the LateUpdate() function void LateUpdate () { if (Input.GetKeyDown (KeyCode.D)) { //delete the next lets say 100 frames...

AppWarp RoomID in Unity SDK

android,unity3d,multiplayer,appwarp
I'm creating app in Unity and faced with problem in room id. I create an "AppWarp Realtime Multiplayer Backend" app in App42 Cloud API but i do not see Roomid varible but it is in Unity. What i'm doing wrong? APP WARP OUTPUT IMAGE UNITY EDITOR OUTPUT...

Unity 5.1 and OnGUI()

user-interface,unity3d
I had the following simple code working, before upgrading to Unity 5 but now nothing happens when I press the Space key! void OnGUI() { if ( Input.GetKey( KeyCode.Escape ) ) { GUILayout.BeginArea( new Rect(50, 50, 100, 100) ); GUILayout.Button("Exiting!"); GUILayout.EndArea(); } } The script is attached to an empty...

Unity WaitForSeconds stuck

c#,unity3d
I tried to create a simple splashscreen. at first this waitforseconds working, but suddenly after a few week this code doesn't want to work. I tried using debug.log but I just get the "before wait" and the "after wait" doesn't appear even after 5 minutes. I am using unity 4.5,...

How to Create Thumbnails in unity

unity3d
I am creating a video player app for android. for that i need to create thumbnails for the videos present in the videos folder. After searching web i could able to understand unity's MovieTexture doesn't support for android. This one i could able to solve using a plugin. For creating...

Formatting large numbers in C#

c#,.net,unity3d,formatting
I am using Unity to make an "Incremental Game" also known as an "Idle Game" and I am trying to format large numbers. For example, when gold gets to say 1000 or more, it will display as Gold: 1k instead of Gold: 1000. using UnityEngine; using System.Collections; public class Click...

Unity3d AudioSource not creatable

c#,audio,unity3d
I have a strange problem in unity3d. I want to use several audio sources for playing a sound with a overlapping effect. Because I can't explain the problem myself- I tried the same with only one AudioSource. So I have this script: public class audioOverlap:MonoBehaviour { private AudioSource sct; public...

2D game development with Unity3D

unity3d,2d-games
I tried to find some answers to a few questions I have about Unity3D games development. I want to create 2D mobile games. The thing I really want to know is if I can create a mobile game for different platforms at one time (as cordova can build Android /...

Coroutine being detected as inactive despite being active

c#,unity3d
In my game, I'd like to have the enemy flash before it does its attack. I created a Flash() coroutine that does this, but when I try to run the coroutine, I get the following error: "Coroutine couldn't be started because the the game object 'Sheep' is inactive!" The thing...

Giving objects unique ids onStart

c#,random,unity3d
I have a bunch of gameObjects that I am assigning unique ids to in the Start function. void Start() { UniqueID = String.Format("{0:X}", DateTime.Now.Ticks); } I thought this would work but every now and then I get duplicate ids. How can I make sure that they are always unique?...

How to access RectTransform's left, right, top, bottom positions via code?

unity3d,unity3d-gui
I have a UI Canvas with render mode world space set. I am seeing 'left', 'right', 'top' and 'bottom' variables in the RectTransform component in the editor. Any ways to access these variables via code?

Press one button, focus all buttons

c#,unity3d
I am trying to implement an inventory system in unity3d. They are several ways to realize an inventory on gui but i've chosen the easiest. Every item on gui is represented as a cell(GUI.Button). Every empty cell means empty place in inventory(GUI.Box). When I press one button to chose an...

Unity An object reference is required to access non-static member C#

c#,unity3d
Im trying to learn C# with Unity engine But a basic script like this: using UnityEngine; using System.Collections; public class scriptBall : MonoBehaviour { // Use this for initialization void Start () { Rigidbody.AddForce(0,1000f,0); } // Update is called once per frame void Update () { } } gives this...

Does the game engine allow me to intergarte native android code

android,unity3d,libgdx,andengine
I am looking into using Game Engine for one of my apps. I have been android developer for a while but never used a game engine. I know the most famous engines out there are AndEngine, Libgdx and Unity Which engine would allow me to use the native android code...

Controlling/moving an object in a circular motion in Unity

c#,unity3d,rotation,position
Basically, I want it so I can move an object left or right, but in a circular motion, rather than a straight line. This is because the object is the child of another sphere, and I want to move the object around the sphere using the left/right arrowkey so a...

Call methods on fields of specific class

c#,unity3d
I need a simple way to call specific method of all fields of certain type within class. (Applies to C#/Unity3D) Example: public class Item{ public void Update(){ } //.... } public class Container{ Item a = new Item(); Item b = new Item(); Item c = new Item();//etc public void...

Unity setting GUIText of another object

c#,unity3d
I have (PlanetController): private GameController gameController; ... void OnMouseEnter() { gameController.setClassText("Orbital speed: " + orbitSpeed); } In the GameController script: public class GameController : MonoBehaviour { public GUIText classText; void Start () { this.setClassText (""); } public void setClassText(string text) { classText.text = text; } } But I'm getting: NullReferenceException:...

How to make the whole scene in dark on unity3D

unity3d
Likes that when the game is pause, only the Resume button is lighted, other whole scene is in dark, Is there some function can do it?

Having data virtualization in Unity3d UI panel

unity3d,panel
I have a UIpanel in my application and i instantiate gameobject in it programmatically during runtime, the problem i have is i have to create more than 1000 gameobjects (sometimes up to 6000) in that panel and that takes a long time freezing the UI and trying it with Coroutines...

Using Switch for Simple Unity3D Patrol Movement

c#,unity3d,switch-statement
I'm using a switch statement to create two movement types on an enemy: Forward, and Backwards. The enemy has three patrol points. When he begins, I want him moving from the first patrol point and adding 1 to the current point when he hits his second patrol point (empty 3D...

Unity Cardboard on Nexus 6 bug: U.I of previous scene is remained on view when new Cardboard scene is loaded

android,unity3d,google-cardboard
I develop VR app by using Unity and Cardboard SDK. My first scene is a non-Cardboard-VR scene contains U.I dropdown list and confirm button. When I execute loadLevel() to the Cardboard VR scene, my previous U.I will still be remained on the view, in corrupted form, behind the rectangular VR...

Google Play Game Service Check user logged in or not Unity3d

android,authentication,logging,unity3d,google-play-games
I want to check user has been logged in or not if it has been logged in then i will check for achievement. I have written like this : void Update() { Social.localUser.Authenticate((bool success) => { Social.ReportProgress("Cfjewijawiu_QA", 100.0f, (bool success) => { // handle success or failure }); }); }...

In Unity3D, How to make the whole scene in dark, but some Area are not in dark

unity3d
I wan't make some teaching levels with UGUI, so need the whole to be in dark, but some rectangular area not in dark. I can make the whole scene in dark by adding a gameobject with a image component, and control it's alpha to dark. But I don't know how...

Unity c# List memory leak

c#,list,memory-leaks,unity3d
I'm getting a serious memory leak when assigning textures at runtime. When useNewArray is true, Task manager shows that Unity's memory usage grows by ~20 MBs / second. The full (183k zipped) project can be downloaded here: https://goo.gl/axFJDs Here's my code: using UnityEngine; using System.Collections; using System.Collections.Generic; public class testMemory...

Unity - Particles emitting non-random

unity3d,particle-system,particle,trail
I am trying to find a way to emit particles in a non-random direction around and away the object. Using the Cone shape, with an angle of 90, the particles fly away from the object, which is good. However, the particles are emitted at a random point, as seen here....

Can an Android (Java not C/C++) plugin alter unity textures?

java,android,unity3d,android-mediaplayer
I'm trying to use an Android plugin to get around the fact that Unity does not support Video Textures on mobile. I do this by getting the texture ID of the texture that will be used for video (supplied by Texture2D.GetNativeTextureID()) which i then pass into the Java Plugin. The...

Unity 3D scripts move multiple objects

c#,unity3d
I have a problem. I'm doing a project in Unity 3D (c#), a 3D worlds editor. My problem is that I want to move multiple objects by selecting them. I managed to move one with my mouse cursor, but for multiple I failed :D This is my code to move...