The tag has no wiki summary.

learn more… | top users | synonyms

-1
votes
1answer
37 views

Float increment give wrong result [closed]

I found something weird with my unity code : public class heroesscript : MonoBehaviour { float counter = 0; void FixedUpdate() { counter += 0.02f; print (counter); ...
-1
votes
1answer
55 views

Yeild waitForSeconds(5.0) is not working

I am trying to call another function continuously from my Update() function. So, I have used yield WaitForSeconds(5.0); but, the it stops for the first 5 seconds and it does not stop the next time it ...
-1
votes
0answers
62 views

Why does this code update my object's position so fast? [closed]

I was working on make my object appearing in the screen in random position. So I used Vector3.Lerp as it was mentioned in this question. I modified the code a bit as I was getting too much error and ...
0
votes
1answer
54 views

Why does this code not update my object's position?

I am trying to move the object in my frame in Time.deltaTime. I have not taken care the speed yet but the problem is, the object is almost at position (0,0) after I have multiplied the x & y axis ...
0
votes
0answers
33 views

How to embed UnityScript for scripting in Unity3D?

It is useful to have parts of your game being scriptable. Many people (especially outside of Unity) are using LUA for that job. As UnityScript (as with Boo or C#) is a first class citizen why not use ...
1
vote
0answers
38 views

How to initialize once for all a static field of a custom editor in unity

I have a custom editor wich has a static field. Suppose you have a static field of type MyObject: public class myEditor : Editor { ... private static MyObject myObj; ... } I'd like to ...
0
votes
0answers
22 views

Unity3D C#: How to resize an inputfield according the content which is set dynamic

I've got an InputField where the text is filled in upon getting a string back from the server. We can debug the entire text so we receive it correctly. However the text is too long to fit in our ...
0
votes
1answer
37 views

Unity3D : Unity fails to detect null objects

im instantiating an object which is gonna play the background music for my game. On the Awake() function I check if there is a gameobject with the tag "MusicPlayer" on it, and if there isn't any I ...
1
vote
1answer
54 views

Unity Raycast shoots right through some objects

I made a melee combat system for my game. The code looks like this: var hit:RaycastHit; if(Physics.Raycast(transform.position,transform.forward,hit)) { if(hit.distance<=2.0) { ...
0
votes
1answer
24 views

Destroy a single list member

im trying to destroy a single game object using the following script but it destroys all of them , not the ones I want. I want to destroy the ones that the transform that holds this script collides ...
3
votes
1answer
269 views

Change unity physics engine speed

Is there a simple way to change the speed* of unity's physics engine like in the game SuperHot? Any script language is ok but javascript is preferred. *I am not sure if speed is the correct term.
0
votes
1answer
99 views

Where should I put code if I want it to run automatically?

I'm new to programming and I found an animation script that has code that is called in the OnMouseDown event, when the user clicks the object. I'd like the code to run automatically, instead of ...
2
votes
3answers
117 views

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

I have a script that expected the game object to have a Terrain component. Is there an attribute I can add (or some other way) which will prevent a designer from adding my ...
0
votes
0answers
32 views

How to control animationClip though scripting or button pressed

I am stuck in my project designing Game Menu in unity. I am using NGUI plugin free version. I created image button and animated in animation view. It made animationclip and added in animator ...
0
votes
1answer
35 views

How to increase the rotation of a quaternion by a percentage of X % in a Unity script?

There is a simple way to increase the rotation described by a quaternion by a percentage X? Sorry, but in the documentation of Unity3D I found nothing and I have a poor knowledge on the topic.
0
votes
2answers
81 views

StartCoroutine function inside TriggerOnEnter2D not working - unity + kinect

So i'm using Kinect with unity to track user's hand movements, and let the user's hand act as a mouse, I have written the code to detect a collision between a button (sprite object) and the hand ...
0
votes
0answers
23 views

Drag object on the XZ plane

I wrote a script to drag an object on the XZ plane. It works good when the object is close to the camera's position. So here is the code: using UnityEngine; using System.Collections; public class ...
-1
votes
4answers
123 views

Scripting vs Programming [closed]

How does using Scripting and calling functions of scripting API differ from programming using C++ in UDK or Unity?in scripting we use the scripting API to interact with the engine and use functions ...
0
votes
1answer
90 views

NGUI Texture Background Font of Sprite

I am new to Game Development and using NGUI plugin free version. There are few sprite images in my game. I made them prefab and instantiated at runtime. then I created NGUI Texture and Made it ...
0
votes
0answers
20 views

iTween.LookTo works only when the boolean gets changed

im trying to rotate an object when the player gets too close to it but it only rotates when the player leaves leaves the range for 0.5 seconds or less. It does the same if i use ontriggerenter and ...
0
votes
1answer
92 views

Random Object in Array

I am using Unity. I have created eight different types of objects, stored in an array, and I am displaying them on the scene in a grid pattern with random order. The first four objects in the array ...
-1
votes
1answer
50 views

How to increase player Lifes count

I am new in Unity Game Development. I am designing infinite game using C# scripting. There are many cubes in my game scene. if single cube is hit by player, He gets 100 points. if same color, two ...
0
votes
1answer
49 views

How to write a unity script to observe the position of a game object (during scene creation)

I want to write a simple Unity script to be notified when a game object is moved, during the creation of the scene. More precisly, I want to write a Unity script that can recognize when the user ...
-1
votes
1answer
124 views

Unity 3D: Raycasting for gun hits

I am having trouble understanding raycast hits in Unity3D. I am trying to create an FPS game, so I have a gun, bullets and so on. My script for the bullets is: var Bullet : Transform; var Spawn ...
0
votes
1answer
63 views

Raycast doesn't point on the right direction

The raycast line im rendering is acting weird, it doesn't point where I want it to. I want it to point from the yellow object to the selected one but it draws it at another position. Here is my ...
5
votes
0answers
73 views

How can I copy an asset folder programatically depending upon a constant?

I have a Unity project in which I have 200 games and some 350 scenes. Now I want to make separate builds for each game. All my assets are present in Assets/IgnoredAssets/ABC folder. To include these ...
3
votes
1answer
320 views

Unity 3d 4.6b New GUI system doesn't take touch when already a touch event is occurring in 3d scene

I know this is beta version but.. I have a Canvas->Button which works fine when I tap it normally. I have a joystick in my scene which is drawn by separate camera other than mainCamera. now, while ...
1
vote
2answers
133 views

Why should I use getcomponent?

I have already referred the animator by using the statement, Animator anim; But,What is the use of getcomponent in awake() function.What happens without it.
1
vote
1answer
322 views

What does Quaternion.Lookrotation do?

I have this code, if(Physics.Raycast(camRay,out floorHit,camRayLength,floorMask)) { Vector3 playerToMouse = floorHit.point-transform.position; playerToMouse.y=0f; Quaternion newRotation ...
0
votes
1answer
59 views

How to make it two seconds for Time.time?

var targetscript : Diamond; var red : Color; var orange : Color; function Start () { gameObject.camera.backgroundColor = red; } function Update () { if (targetscript.score > 4) { ...
0
votes
1answer
33 views

Align SpriteText position

i have this function which aligns text. static function AlignTxt(obj : GameObject, txtAnchor : SpriteText.Anchor_Pos, txtAlign : SpriteText.Alignment_Type) { ...
4
votes
1answer
208 views

Prefab random rotation in editor

Is it possible to automacicaly random rotate pefab during placement in editor in unity 4.5.3? I can make it autorotate in game(at start) but I want it to be visible in editor and at fixed rotation ...
1
vote
1answer
117 views

touch.phase == TouchPhase.Canceled not worked

i m tired to handle and solve issues related to multitouch. i m use maximume 5 touch simultaneously but when two touches are down on two object and i moved my fingures then that both touches fired ...
0
votes
2answers
334 views

Instantiate prefab randomly but not in already occupied position

I want to generate bubbles randomly on screen. When a bubble is generated in one place then other bubbles should not be generated near its radius 1 area, so they can not collide or trigger with any ...
-2
votes
2answers
156 views

AI shooting through walls [closed]

I made a AI shooting script for my new game but the problem is that the AI ignores the walls and shoots through walls. This is my ai script : #pragma strict public var rocketPrefab : Transform; ...
0
votes
2answers
43 views

different Scenes but each of them loads per frame

well i want to have something like restaurant that divided in 3 sections.and the user can switch between these but every Scene loads every frame.for example the character is in the first section and ...
2
votes
2answers
174 views

How to be sure that a target goal in a match 3 game level will not be impossible?

This is clearly not a coding problem but the logical one. I am starting to learn how to make a match 3 game. but there is a question rising in my mind. when i will set goal to complete the level, how ...
0
votes
1answer
200 views

Unity3d : Make prefab follow raycast hit

I've been trying to make a weapon script which fires a projectile (prefab) straight forward.I added to the bullet the first script shown here.And the second one to the main camera.The problem is that ...
-2
votes
1answer
208 views

Animation not playing correctly(or at all)

Im created this script which plays animation/s when the player goes close to it and presses e while aiming at it.For some reasons only the first animation is playing,not the second one.Is there any ...
0
votes
1answer
276 views

Generating a particle effect on top of a GUIElement (Unity)

I am working in Unity on a 2D project which is using C#. I have a number of guitextures which are hearts in order to create a sort of life meter. I would like when the player loses a heart for the ...
-1
votes
1answer
89 views

Unity3d : Animator canceling script

I create a sway script for my flashlight and attached it to the gameobject(flashlight). Now the problem is that when I enable the animator in the gameobject(flashlight) the sway doesnt work,but when ...
0
votes
1answer
671 views

Unity Android Unable to convert classes into dex format AdMob

I'm a beginner Unity programmer (school-age), so I don't know that much about the system. On its own my app compiles fine, but when I implement the AdMob SDK (Google) 2.1, I have the following error ...
1
vote
1answer
88 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 ...
0
votes
2answers
128 views

Make a square flickering at a preset frequency

I'm working on a medi-sci project where I want the patient to use brainwaves to exercise control the environment. The environmnet is a 2D game where the game character is to be controlled by 2 ...
-1
votes
2answers
244 views

How can I read inputs from buttons at the same time?

I am using the tk2d toolkit. For my project, each player has their own button. I need to be able to get both buttons inputs (at the same time) so that I can figure out which up event first. I run ...
3
votes
1answer
661 views

How to compress Unity apk output?

I made a game with Unity but the size of .apk file got so large, it is about 70mb... Is there some way that I can compress my apk file?
0
votes
1answer
273 views

Make GuiText responsive

I'm using C# code to make a responsive GuiText. I was abel to make a responsive GuiTexture, but I'm struggling with doing the same for a GuiText. Code for the responsive GuiTexture using ...
-2
votes
1answer
459 views

Unity3D - Clones won't get destroyed by script

I need some help making this script work. #pragma strict function OnMouseDown () { Destroy (gameObject); } Basicly what the script does is that it destroys the objects that the player clicks on.I ...
0
votes
4answers
982 views

Scripts won't affect clones - Unity3d

I made a script which swaps two game objects on click.But the script won't work because the objects are actualy clones of the original prefab. This is the script (UnityScript): #pragma strict var ...
0
votes
1answer
151 views

I want to make a pause button on the scene

I want to make a pause button on the scene. If I press the button it will show the guiTexture with a variety of buttons with each different script. So what steps should I take? 1. How do make it so ...