If it returns something else - say, a double - then you'll run into problems, the easiest solution of which is to change its return type to float.Īnd oh hey, look at that, there's the problem in snippet 3. So, check HorizontalAngle and make sure it's a function that takes a Vector3, and returns a float. (There are exceptions - integers will generally convert to floats just fine, but it never hurts to throw in some extra f's just in case.)įor the second one, Mathf.DeltaAngle is pretty simple: it wants two floats. You have a 2 without the f here try making it 2f and see if it gets better. Where is animationComponent declared?Īlso, you'll often get that "invalid argument" error in C# if you don't stick an "f" at the end of just about every numeric literal. Normally we capitalize function names, so I wonder about that. This code would be valid only if you have a function called animationComponent somewhere, that takes a string parameter. OK, on the first one, I'm not sure, but "animationComponent(bestAnimation. Good luck! Make sure to take the time to understand what you're doing and why. And if you mis-connect (or fail to connect) an inspector variable, you'll probably get runtime exceptions, or things just will fail to work.īest practices specifies making what is known as a "Unit Test" in order to verify your script in one language functions identically to the script in another language. If you introduce an error early on and don't catch it, you'll be very puzzled later on. The key is to change in small steps and understand all of your changes, and make sure to reconnect all the relevant inspector public variables and TEST AFTER EACH SCRIPT that you convert. Try perhaps making a scene using the Unity Standard Asset CameraFollow.js script, and then try converting that. You might have more luck if you start on a smaller set of files first. When you get that one script running (and fully tested!), then move onto the next-smallest script. I assume you're just doing this for the exercise in coding, so let me make some suggestions:Ĭonvert just one script to start with, perhaps the smallest script, and only convert that one script.
0 Comments
Leave a Reply. |