Answer by T27M
You have a few variables in the wrong place, make sure you set the values of sphereSpeed and leftRightSpeed in the inspector. GetAxis returns either -1, 0, or 1. You are taking that value and...
View ArticleAnswer by T27M
Destroy() and Instantiate() are (or so I'm lead to believe) relatively heavy operations to perform, especially if the object you are creating/destroying is complex. From what I can see here that might...
View ArticleAnswer by T27M
Your code is right, but I'm guessing you are only calling the spawnEnemy() function when you spawn an enemy. Here's how I would do it. - Create a prefab of your enemies with a ridgidbody and a move...
View ArticleAnswer by T27M
Vectors aren't Unity specific. [Search engines are your friend.][1] [Vectors Third Party][2] [Unity Learn Primer][3] [1]:...
View ArticleAnswer by T27M
I asked the question a different way on SO and got an answer. **Copied From Answer** Basicly you should get all the types from collections using Linq and then compair the result. var...
View ArticleAnswer by T27M
Make some graphics e.g buttons, icons etc. Site them as sprites, use a separate camera to render the UI over the game camera. Attach a 2D box collider to each sprite and a script that does something...
View ArticleAnswer by T27M
So with the information in the question this answer is based on a lot of assumption, here is what I think is going on. I'm assuming your "killer" gameobject does something like void OnTriggerEnter2D...
View ArticleAnswer by T27M
Try this instead. public GameObject deathExplosion; void OnTriggerEnter2D (Collider2D blastCollisionCheck) { if (blastCollisionCheck != null) { if (blastCollisionCheck.gameObject.tag == "Blast") {...
View ArticleAnswer by T27M
You can calculate and store each distance in a list and using the list's Sort() method, you can sort them from lowest to highest. public List objects = new List (); List distances = new List (); // Use...
View ArticleAnswer by T27M
At line 16 in the code above grabBlackClonesArray = new GameObject[3]; This will declare an array of 3 elements (0,1,2). It is 0 index, but you still declare the size as the number you want i.e if you...
View ArticleAnswer by T27M
The following works for me and I am unable to type anything, but numbers into the textfield. int guiInt = 0; void OnGUI() { GUILayout.BeginArea(new Rect(10.0f, 10.0f, Screen.width - 20.0f,...
View ArticleAnswer by T27M
You almost have it, I actually just implemented this the other day. I use this in a generic way for any serializable object as part of a "Helpers" class along with other useful functions. public static...
View ArticleAnswer by T27M
My money would be on your call(s) to GameObject.Find (). GameObject.Find() isn't the most efficient method, plus you are calling it multiple times since you have it in Update(); If you're going to use...
View ArticleAnswer by T27M
Heh, I made this mistake ;) http://docs.unity3d.com/ScriptReference/Collider2D.OnCollisionEnter2D.html
View ArticleAnswer by T27M
GetKey is correct, but I think it's because you have moveDirection *= speed; and moveDirection *= sprint; both working against each other. Try modifying it to this: if...
View ArticleAnswer by T27M
Your code doesn't make sense to me. Why are you calling this from OnGUI? You can use the OnMouseDown() function to detect when a gameobject has been clicked. Alternatively you can use this line of code...
View ArticleAnswer by T27M
You can do this with a trigger, check out this [video][1] for more information. [1]: http://unity3d.com/learn/tutorials/modules/beginner/physics/colliders-as-triggers
View ArticleAnswer by T27M
Delete line 8 you don't need it. Your OnGui function starting at line 12 should be all caps function OnGUI{ } It looks as if you are trying to call OnGUI, you don't need to do this it will be called...
View ArticleAnswer by T27M
Use the [ToString][1]() method and you need to [concatenate][2] the string. Application.CaptureScreenshot( "../../../../DCIM/Camera/screenshot"+ count.ToString() +".png"); count++; [1]:...
View ArticleAnswer by T27M
Does this do what you want? if(Input.GetKeyUp(KeyCode.Z)){ transform.RotateAround(transform.position, new Vector3(0,0,1f), 180f); } [RotateAround()][1] [1]:...
View Article
More Pages to Explore .....