Countdown timer trouble?
I have a script that with the use of a GUIText object, displays the time left before the game is over. The time begins from 15 and reduces. If it reaches 0... game over. I have a question regarding...
View Articledynamic typing in Unity iOS: ...not a member of 'UnityEngine.Component'
Ive read here about a similar problem with dynamic typing in Unity iOS, where one doesnt get a warning just until they try to build.I have this function for example in a script:function RecountEmpties...
View ArticleUsing JavaScript and C# inside one script
In the 4 months I'm using Unity, I've only used JavaScript.I believe I'd read that one can use JavaScript AND C# in the same script, but I cannot remember where.If this is correct, what script should...
View ArticleList class in iOS (C#)
Is it possible to use the List<> class in iOS?What I want to do is have a List that gameObjects are added to and removed from at runtime.Afaik such a thing can only be done through Lists.If the...
View ArticleAlpha-test VS Alpha-blend shader
Making an iOS game. I've read in the Unity Manual --> Optimizing Graphics Performance, the following sentence, which I have trouble understanding:Contrary to the desktop, alpha-testing is very...
View ArticleUsing a pool of objects that will be spawned ONCAMERA and removed OFFCAMERA...
I want to use a pool of prefabs that will be randomly spawned on (random) squares of my board every 4 and collected (and removed from the board) by my character.The board has 48 tiles, one of which is...
View ArticleActivating & Deactivating prefabs from a prefab pool VS simply moving them on...
I use a prefab pool, instead of instantiating and destroying prefabs of collectibles that get spawned in my game and collected (hence removed from view). The game is for iOS.The prefabs pool is a group...
View ArticleMaterial class use general question
In my JS I set a material variable:var someMaterial: Material;and later I want to test if the object that collides with the object that has this JS attached on it has "someMaterial" and do something:if...
View Articlecontrol over the possibility of a Random.Range function from an array's elements
(I'm really sorry if the title is a mess, I can't put it simply in a few words)I have a built-in Array, "myArray". Right now, I use this:randomArrayElement = Random.Range (0,myArray.length);to pick a...
View ArticleCall a function repeatedly while a boolean is true
I have a variable: boolean, that under certain conditions turns from false (default value) to true for a limited time and then automatically it goes back to false. While it's true (eg for 5''), I want...
View ArticleAccessing a js static var from a c# script
I have a static variable inside a JavaScript script. How can I access it from inside a C# script?
View ArticleSwitch use for multiple cases
I have an integer, that can have values from 1 to 100.I want to define the behavior of the game, depending on the value of the integer.If it's smaller than 10 I want thing A to happen.If it's equal to...
View ArticleToggle SOUND from main menu and in-game (iOS)
I'm making an iOS game with no music, just sfx. I want to toggle it on/off from a main menu's button and from an in-game button. What function will this button have to call?
View ArticleInstantiate a prefab every certain distance while swipping (iOS)
I'm touching the touch screen and a prefab is instantiated where I have placed my finger. Now, keeping my finger on the screen, I begin to swipe. A prefab's clone is instantiated every say 10 pixels....
View ArticleIs there a way to disable the rotating black border when rotating the iphone?
Since my iOS game is played only in portrait mode, I don't see any reason for the accelerometer to work (and consume energy). Plus, whenever I rotate the device, I see this black border that rotates to...
View ArticleHow do I prevent iOS keyboard from using anything BUT English?
How can I prevent the use of anything but English keyboard (iOS) when iPhoneKeyboard.Open() is called? (prevent players from typing in their own language)
View ArticleUpdate function in a UnityScript attached to 50 clones of a prefab: heavy or...
I'm planning on making a scene with 50 clones of a prefab. This prefab has a Unity Script attached on it. The script contains an Update function. I've read that separate Update functions pose an extra...
View ArticleDifference between "lifetime of the script instance" and...
I've got a question regarding the following sentences taken from the Unity Script Reference: *"Awake is called only once during the lifetime of the script instance."* *"Start is only called once in the...
View ArticleHow do I put a "Rate game" button?
I want to have a button on the start screen, that when pressed will get the player to the game's page in order for the player to rate it. Could anyone please guide me on how this is done? Thanks :-)
View ArticleInvokeRepeating gets cancelled on scene change?
I use MonoBehaviour.InvokeRepeating to call a function every few seconds. If I load the next scene, will the Invocation get cancelled automatically or I have to cancel it manually using...
View ArticleRandom number from a specific group of numbers? (not Range)
Taken from the Scripting Overview: ***// Loads a random level from the level list*** ***Application.LoadLevel(Random.Range(0, Application.levelCount));*** If I had for example 10 levels, how would I...
View ArticleCount Builtin Array elements with a certain property.
I have a builtin array with 50 elements: var Tokens : GameObject[50]; The transform.x of the Tokens changes when the game runs. I want to know each moment how many of the Tokens have a `transform.x...
View Articleproper usage of GameObject.GetComponentsInChildren
I have a parent object called ***PackedSpritesParent***, that has 50 children that contain a ***PackedSprite*** Component (from the SpriteManager2 Plugin). On game start I want to populate an array...
View ArticleVariable inside a function's NAME - does it work?
I have 10 functions: function MyFunction1(){ } function MyFunction2(){ } function MyFunction3(){ } ...etc Is there a way to call a specific function depending on the value of an integer i that takes...
View ArticleIs it bad to use long variable names?
for example I declare this variable: var EnergyTokensGoalTarget: int While this variable's name is very helpful being so descriptive, I'm wondering if excessive use of names that long (for other...
View Article[PlayerPrefsSet...] VS [var=...] at every value update
I understand that using PlayerPrefs to set data values is not slow, even when done for lots of different data at once, but still I would like to know if it's better: 1) updating e.g. the total tokens...
View ArticleAre Apple's iOS promo codes version-dependent?
So if I update to version 1.1, the promo codes that I had gotten while v.1.0 was live, are no longer valid?
View ArticleUnity 5.6 / C# error CS1061
I've upgraded my project from Unity 4 to 5.6 and I get a bunch of errors. One of them is on a line which was written like this in Unity 4: //ActiveNPC is a Transform and I am deactivating it's Animator...
View Article(C#) How can I toggle "Simulated" in a Rigidbody2D?
on a gameObject with several children, all of which have a Rigidbody2D component, I want to enable (or disable) the "Simulated" property on the Rigidbody2D, using:...
View ArticleDrag and drop (with snapping) a 2dSprite for a Dress Up game
I'm trying to make a dress up game, in which clothes will appear in a closet and the player will drag-drop (with snapping) them on the character. I followed this excellent tutorial by quill18: [youtube...
View Article
More Pages to Explore .....