0
votes
1answer
24 views

Prefab disables its script when a clone is instantiated

A clone of a cube is spawned when it is destroyed, however the clones disable the script in the editor (example: http://gfycat.com/SnarlingScornfulEgg). Used the exact same script for a different kind ...
2
votes
1answer
33 views

How do I change the material of an object with Script in Unity?

I was making a game with Unity and I want to change an object's material using JavaScript when the player collects 5 collectables that I made. The collectables get stored in an int variable called ...
2
votes
1answer
39 views

How do I save variables and load them in Unity with JavaScript?

I made a game and i want to save the high score and load it back. I need to save 3 variables and load them when the game starts. How do i do it?
1
vote
1answer
34 views

How do I use elapsed time as the player's score in Unity?

I'm making a "survival" game, where the goal is to stay on a rotating board as long as possible. I want to add a score system based on how many seconds passed. For example, if you stay on the board ...
0
votes
1answer
41 views

Move camera from wherever camera is to pinned point

So, I need to switch/ move/ animate camera from point X (not point A,as I don't know where the camera is at that momemnt) to point B (place where you want your camera to move). This is for ...
1
vote
1answer
52 views

Objects don't instantiate at mouse position

I'm trying to get the player to shoot a projectile at the mouse position, however the projectile is shot in weird directions (http://gfycat.com/BothFluidHoneyeater). Here is relevant part of my ...
0
votes
1answer
21 views

Align SpriteText position

i have this function which aligns text. static function AlignTxt(obj : GameObject, txtAnchor : SpriteText.Anchor_Pos, txtAlign : SpriteText.Alignment_Type) { ...
14
votes
3answers
3k views

How to avoid movement speed stacking when multiple keys are pressed?

I've started a new game which requires no mouse, thus leaving the movement up to the keyboard. I have tried to incorporate 8 directions; up, left, right, up-right and so on. However when I press more ...
-2
votes
1answer
132 views

Energy Bar in Unity [closed]

I want to display a debug message when the progress bar is loaded fully and I have a button "refresh", when I click this it should reload the progress bar. Here is the code I have tried: var ...
0
votes
2answers
124 views

Deal Damage to Player

I have to make a simple "avalanche" game to show I know how to use the physics and creating terrain. But I actually wanted to go a little above and beyond and actually give the player health so there ...
-1
votes
1answer
55 views

If object is bellow another object… do something [closed]

I have 2 objects in scene. When pillar is bellow target, pillar object needs to animate. I get this error: "NullReferenceException: Object reference not set to an instance of an object". var pillar : ...
0
votes
2answers
164 views

Health bar in unity

I have created a button as my health bar and it must decreasing after a specified time.Here is the code I have written.But the problem,this code is working in the form "Its decreasing the button ...
0
votes
1answer
169 views

How to enable/ disable GameObject

I have child object with ParticleSystem component. I want to have particles disabled until I press button. I unchecked child object to make it disabled but when I press play it enables ...
1
vote
4answers
98 views

Check which object was activated first

How do I check which object was activated before the other? Let's say that there's door to open. To open the door you need to press firstly the second button and then the first button...but not the ...
0
votes
1answer
99 views

Press multiple switches to unlock the door

I made 2 scripts, one that is a switcher and one that checks if object is switched (Switch, SwitchCheck). Switch script (it's on 2 objects that are switches and both objects have colliders with ...
0
votes
2answers
112 views

How to show a float with no decimals [closed]

I want to show the current health and stamina of the player using GUI.Label. All is working fine however it shows the values with decimals to the millionth (example: ...
-1
votes
2answers
63 views

Character bounces/stutters down hills

I'm using Unity3D (not 4) and I'm experiencing a bit of a problem with character movement. I'm using a cylinder as a First Person player with a child Main Camera. In this cylinder is the stock ...
0
votes
1answer
60 views

Continous collision happening in Unity2d

I am working on Unity2d. I have a game object called gameobject1 on screen. It holds an image (named "state"). When I drag a tree on a gameobject1 collision is happening continuosly in the same layer ...
1
vote
1answer
68 views

How to use sprite as font in Unity?

I've started working on my first game in Unity; It's very simple, there's a spinning block in the middle, and there are spinning blocks coming from all sides. When they hit the middle block, you lose ...
1
vote
3answers
158 views

Freeze Player position temporarily?

I'm making a 2D sidescroller (although it's technically being made in 3D), and I need to freeze a player's position temporarily. With a RigidBody, this would be simple, but I can't think of how to do ...
-1
votes
2answers
79 views

C#Script select GameObject

I want to load the prefab instead of the gameobject that is in the screen, my code is this one: using UnityEngine; using System.Collections; public class Arma : MonoBehaviour { public static int ...
2
votes
1answer
156 views

Inverse Explosion with Unity2d

I am currently trying to make all other objects push away from the player when the player explodes. It currently works, but it pushes close objects a little and far objects very far. What I want is ...
0
votes
1answer
168 views

Problem with Raycasting in a 2D Game

I'm new to using unity and came across a problem when I was following a tutorial. The game is in two dimensional space, and when my player walks over a certain tile the detection never goes off. ...
1
vote
1answer
251 views

Unity3D - Android pause screen - double click issue [closed]

I made a pause script for the game im developing for android. I added the script to the GUITexture I created and placed on the top right side of the screen.The issue stands at the part where if the ...
4
votes
2answers
995 views

How to ignore collision between two objects

I have a player that shoots in the direction that it is facing. However, the shot that is created when I click, also destroys the player (example). How would I make the shot ignore collision with the ...
3
votes
3answers
161 views

How to launch a prefab at the mouse position

I want to use Instantiate(item, new Vector3(...), Quaternion.identity) to land an item at the position that was clicked. My game is using a third-person view (example). This is the code that I think ...
-1
votes
4answers
205 views

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

The game is supposed to increase the level by 1 every 10 spawns of an object, using totalShots % 10 == 0. So, when totalShots is equal to 10, 20, 30, etc. the level should increase by 1, however, the ...
0
votes
1answer
419 views

How to randomly spawn object using instantiate

I'm trying to spawn objects which move in one direction until they hit a player or the barrier. The spawner is a cube which moves between two points to spawn the object at different locations. The ...
1
vote
2answers
163 views

Object goes straight through game object without colliding

The "shot" is supposed to collide with the left bumper and then be destroyed, but the shot goes right through it. Both objects have a box collider. The following is the code I am using: #pragma ...
2
votes
0answers
61 views

Certain sound is played after last if within script [closed]

The idea is to make the sound work when comboTime is false. However, it works in an unexpected way: the sound works after the last if statement within ComboHud.js, which is: if (Time.time > ...
1
vote
1answer
369 views

How do you set the target location for a navmesh using a GameObject?

I am trying to get a GameObject to navigate through a map and get to the exit. I have created a navmesh for the map and given the player GameObject a navmesh agent. The exit is marked with a empty ...
0
votes
1answer
70 views

GameObject remains null for some reason

The idea is to access the function BlockWasDestroyed(); from Combo class. Instead of var combo = gameObject.GetComponent(Combo); I've also tried with var combo = GetComponent(Combo); var ...
2
votes
2answers
596 views

android game development using unity 3d [closed]

I want to learn android game development. I dont have any programing knowledge. So should I learn JAVA and eclispe to develop games for android. Or should I learn Unity 3d. And is knowledge of java ...
0
votes
1answer
388 views

Error when using GetComponent (Object reference not set to an instance of an object)

I'm using a textmesh to check variables in real time. Thing is if I use AddComponent within Update(), it obviously starts spamming and slows the game. If I try with GetComponent the error is the ...
1
vote
1answer
39 views

Wrapping each script with classes causes errors

The goal here is to change variables from another script. Thing is that they must be in classes, so for example I wrapped this code (which is from PadControl.js): #pragma strict public var ball : ...
1
vote
1answer
131 views

Can't edit specific variables from the inspector panel, while variable is static

In order to make the variable accessible from other classes, I have to make it static. When I make it static, I can't edit it from the Unity's Inspector panel. No way to be able to do both: ...
0
votes
1answer
42 views

What is the actual formula to find the vertices of an animation frame in using a BVH file?

I've read this tutorial and tried many formulas to build the skeleton. I am able to build it without the rotations, but those break everything. This, for example, is a simplified code for one of my ...
0
votes
1answer
174 views

How to play a video on a TV model inside a game?

I am new to Unity3D. I need to know how can I play news when I switch on a TV using any scripting language in Unity3D ?
5
votes
3answers
1k views

Differences between C# and Javascript for Unity [closed]

Apart from the language differences (class-based vs prototypical, strong vs weak typing), what are the differences between using Javascript and using C# when developing games in Unity3D? Is there a ...
1
vote
1answer
438 views

How to continuously create objects in front of the camera when moving forward?

I have created a scene in Unity3D that's filled with spheres. I want to be able to move forward forever and still be passing through the spheres. I was thinking I'd keep the player in one spot and ...
0
votes
2answers
112 views

Unity3D JavaScript/.NET code throwing compilation error with a List-thingy [closed]

So, I do this: var intlist:List.<System.Int32>; intlist.Add(1); And where I say intlist.Add(1) I get: NullReferenceException: Object reference not set to an instance of an object Weird, ...
1
vote
2answers
2k views

Pass parameters from html page to start() function in unity3D webplayer application

I want to pass a parameter from web browser to Unity3D web player as soon as it is loaded. I know that, as soon as the web-player is loaded, the start() function is execute inside web-player. So I ...
1
vote
1answer
947 views

Get MonoBehaviour components from Prefab

I need to assign the script values for the following Prefab in Unity 3.5 The structure is the following Kinect_Prefab -MonoBehaviour ·Script: Missing Mono Script -MonoBehaviour ...
1
vote
2answers
509 views

Dynamic Textures

I am pretty new to this 3D designing and animating, and as an indie developer I need to do everything on my own I have created this simple box character And I want to texture it, have looked around ...
2
votes
2answers
476 views

How to make a Unity3d program/plugin and publish it on Asset Store?

I want to make a plugin for Unity3d, like TornadoTwins's FPS Control. How can I do that? I already have Visual Studio 2010 installed.
0
votes
1answer
832 views

Unity - Code is fine in the editor, has error on android

Right. Im running into some weird issue with android unity. I have this bit of code function OnTriggerStay (other : Collider) { if(die.GetComponent(DieScript).sideUp ==6 ...
2
votes
1answer
2k views

Unity3d - setting gameobject position by percentage of view

I am having trouble finding a way to set a gameobject's position with regards to the screen size. I am building a 2d game that I will be putting on iPhone, iPad, and Android. I need to be able to set ...
2
votes
2answers
3k views

Creating an object in javascript with unity (unityscript)

So I have a ton of experience with JavaScript (its what I do for a living) but I am new to unity. I have built a game engine in javascript but now want to move it over to unity. I have been trying to ...
2
votes
4answers
2k views

Unity: Assigning a key to perform an action in the inspector

I am trying to write a simple piece of code in JavaScript where a button toggles the activation of a shield, by dragging a prefab with Resources.load("ActivateShieldPreFab") and destroying it again ...
1
vote
1answer
604 views

Performing simple network call to retreive JSON in Unity?

I have looked at the network documentation for Unity and most examples seem to be related to networking your game for multiplayer. I am just looking to grab a JSON response from an API for dynamically ...