Answer by Flynn
Mathematically calculate your rotation based on speed: float rotX = (verticalSpeed / maximumVerticalSpeed) * 45 IF the object is traveling downwards at maximum speed, this will return -45. It will...
View ArticleAnswer by Flynn
var testing : Test = new Test(); This goes into memory handling in code -- There are two types of variables, basic variables, and objects. Basic variables are ALL either a number type (float, integer,...
View ArticleAnswer by Flynn
There is a slight trick you could use: For simplicity, let's say we have a cube with a script with an int value. It is from a prefab. We have two prefabs in the scene which are exactly the same, wit...
View ArticleAnswer by Flynn
Physics.Raycast does not take a rotation, it takes a direction. (1, 0, 0) is a direction that points in the X axis direction, but is not rotated 1 degree on the x axis. (0.5, 0.5, 0) would be a...
View ArticleAnswer by Flynn
Okay... Player.PlayerObj = GameObject.Find("Player"); Since GameObject.Find() will not return an error if no object was found, this is not causing the error. Since assigning any variable, even a null...
View ArticleAnswer by Flynn
This is a truly strange one! Before I go any further, it is important to note that the type of array you are using is not native to JS. It's actually a Unity3D tack-on! (From C# .NET, SEE:...
View ArticleAnswer by Flynn
The two ways to do this are: A: IN the import section, turn "Generate Colliders" on. B: Select your object, click COmponent > Physics > Mesh collider (Thanks for the save there, syclamoth, edited...
View ArticleAnswer by Flynn
Event listening in programming is very interesting, and there are many different approaches. The way Unity does it is less event listening, and MORE event describing. The class MonoBehaviour all ready...
View ArticleAnswer by Flynn
THat requires maath lol. You would need to get into a lot of polygon math in order to define custom shapes for your spawning "area" A simple solution would be way easier, you just need to make a...
View ArticleAnswer by Flynn
If I get you correctly, you are just clicking sync and then looking in your IDE. I successfully used Mododev for debugging in Unity in the past, but it was quite a while ago, and I'm afraid I cannot...
View ArticleAnswer by Flynn
Use tranform.InverseTransformDirection(dir); To convert local directions to global coordinates. For example: rigidbody.AddForce(tranform.TransformDirection(inputVector * MoveForce), ForceMode.Force);...
View ArticleAnswer by Flynn
Any changes done while the game is playing are undone when the editor stops playing. Make sure you add your scripts while the editor is not playing
View ArticleAnswer by Flynn
For simple rotation, definitely just write a script. Animations themselves are backed by far more complicated scripts that deal with interpolation types, beziers all kinds of things, as well as reading...
View ArticleAnswer by Flynn
function ammoPickedUp (ammoPickUp : int) { if (ammoMG <= 200){ ammoMG += ammoPickUp; } } Let's walk through this. If you have 199 bullets left, and you ask it to add ten, then first, it will check...
View ArticleAnswer by Flynn
rigidbody.isKinematic = true; Will cause your rigidbody to cease calculating. If you set it to true again, it will pick right back up where it left off :) So yes, isKinematic will pause your rigidbdy...
View ArticleAnswer by Flynn
1. Go to your project, and click create > new prefab 2. Drag the projectile you have in your heirarcy onto the new prefab 3. Rename the prefab as you like 4. Drag the prefab from the project folder...
View ArticleAnswer by Flynn
Unity gets confused when there is a folder named Assets in your project, you will need to rename it: Close the project, then click on Open Project, click the find button, and click on your project...
View ArticleAnswer by Flynn
You can do this without JS thankfully! :) Just start your webplayer up like this: unityObject.embedUnity("unityPlayer", "fit2cure.unity3d", "100%", "100%", params); Then carefully set up all of your...
View ArticleAnswer by Flynn
C# is a bit more strict with how you are supposed to do things than JS -- It wants your functions to be clearly defined as iterator blocks, and it wants you to strictly call them using StartCoroutine....
View ArticleAnswer by Flynn
Using AOV instead of FOV might help! public var minFOV : float = 1; public var baseFOV : float = 0; public var czoom : float = 0; function Start () { baseFOV = Camera.main.fieldOfView; } function...
View ArticleAnswer by Flynn
Unfortunately, the answer appears to be no. :( You can double check this yourself by going to [http://docs.unity3d.com/Documentation/ScriptReference/MonoCompatibility.html][1] I believe that "Micro"...
View ArticleAnswer by Flynn
If I understand your requirements, this should work: Vector3[] vertices = new Vector3[faces.Length*3]; int[] tris = new Vector3[faces.Length*3]; for (int i = 0; i < faces.Length;) { for (int j = 0;...
View ArticleAnswer by Flynn
Theoretically, setting timesScale to 0 right when you press the New Game button would work (unless you have some kind of crazy cool animation going on), however, if that is not an option, you can try...
View ArticleAnswer by Flynn
You will need to encapsulate your integers in a Vector3, like this: if(Input.GetMouseButtonDown(0) && collider.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, (Screen.height...
View ArticleAnswer by Flynn
Hello, there! First of all, I suggest that instead of using boolean signals to tell SpawnEnemy to spawn, that you instead go a little more directly: ###EnemySpawn.js: #pragma strict var prefab :...
View ArticleAnswer by Flynn
Honestly, there really aren't many ways to clean up your code's redundancy (without seriously overcomplicating your code and getting into sticky things like delegates...... blech). However, one last...
View ArticleAnswer by Flynn
That depends! Generally, if you are developing for web-player, do NOT exceed a 700 pixel height. Many users have smaller screens, and on top of that, the web browser will eat a good 100 pixels of that...
View ArticleAnswer by Flynn
GUI.Enabled is intended to be used in the OnGUI() function -- The idea is that you set GUI.Enabled to false right before the code that draws the button, then set GUI.Enabled back to true right after...
View ArticleAnswer by Flynn
**TL;DWR:** ***Use AddTorque without considering what point on the object you are applying torque at. This is the physically correct way to do it, and is equivalent to Lockstep's solution, except that...
View Article