Search Unity

Multiplatform Scripting

Discussion in 'Scripting' started by NOVASOFTproductions, Aug 29, 2011.

  1. NOVASOFTproductions

    NOVASOFTproductions

    Joined:
    Aug 26, 2011
    Posts:
    132
    Ok, so I'm looking to create a multiplatform fps and I've been searching around for the different languages to use, seeing as I'm looking to learn them.

    This is what I've picked up:

    I'm told C# is very good and flexible but after some research I've pretty much found that it's a right arse to develop multiplatform applications with.

    C++ is supposedly good and the best of the C languages, but Unity only supports it through plugin, for which I need Pro. Money is a limiting factor, however.

    Which brings me onto Java. (JS?) Is this the better one of the three to use in this sense? I need it to be crossplatform (windows and mac) and network between the two platforms. Will Java (JS?) do this and if so is that the one that I have the best bet learning?

    I'm working on a mac if that makes any difference.

    Thanks
    Ben
     
  2. jedy

    jedy

    Joined:
    Aug 1, 2010
    Posts:
    579
    Java and Javascript are two different things, note that.

    Use any of the supported script languages, and compile the game for the target platform. This should work... most of the time.
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Use either c# or js. It doesn't matter which.
     
  4. NOVASOFTproductions

    NOVASOFTproductions

    Joined:
    Aug 26, 2011
    Posts:
    132
    Ok, thanks

    I'll try JS, considering it's a bit more simple than C# and I don't fully understand the framework behind it yet.
     
  5. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
  6. NOVASOFTproductions

    NOVASOFTproductions

    Joined:
    Aug 26, 2011
    Posts:
    132
    I barely no anything about that :p

    I'm planning on going into embedded systems and iirc JS is somewhat similar to C++ so I'll learn that for experience.
     
  7. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    False. :eek:

    False! ;)

    The RSS feed is flooded with the same typecasting problems day in and day out now. C# can do everything JS can, and more. I got my start in JS but I wish it were never an option for Unity.
     
  8. NOVASOFTproductions

    NOVASOFTproductions

    Joined:
    Aug 26, 2011
    Posts:
    132
    So... C#?
    if so, can you recommend a tutorial that is mac friendly? I've looked at some but they work through windows compilers and .exe files :(

    Basically, I need someone to help me get the ball rolling :(
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'll fly the flag for js to the bitter end, and when the hordes of C# users surround me poking at my mighty heroic frame, I'll roar and cast them down with my transform.position.x = 10;
     
  10. NOVASOFTproductions

    NOVASOFTproductions

    Joined:
    Aug 26, 2011
    Posts:
    132
    *facekeyboard* :(
     
  11. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    Didn't think you did, I was merely pointing out that you could do it :D.
     
  12. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    I don't know. When I got started, I just read some C# books from the library; I didn't even try compiling. I use OS X exclusively. You can change the language used by the Unity scripting reference, to show you how to put simple examples together, and combine that with book-learning, and the MSDN, which is a reference I use regularly. (It's also a reference for UnityScript, although it doesn't look like it.)

    Prime31 has some good tutorials about more intermediate-level features that are C#-only.

    Unfortunately, you can't get around that in C#, but you can make transform reference to a specific Transform, and do whatever you like with it:

    (code coming in a few)
     
  13. NOVASOFTproductions

    NOVASOFTproductions

    Joined:
    Aug 26, 2011
    Posts:
    132
    Thanks, I'll take a look
    I've been keeping my eye out for c# books but when I saw that it was all .NET based (microsoft) it threw me and I wondered if it was the right language.
     
  14. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Unity scripting, regardless of what language you use, is based on Mono, which is an open source implementation of .NET. This makes it easy to get (non-Unity) code examples of C#.

    The web filter is up again at my day job so what I was going to post above will have to wait. No big deal.
     
  15. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Extension methods and variable hiding are not available in JS. They're more important to me than being able to directly operate on a struct component, but I wish I could do all of that.

    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public static class ExtensionMethods {
    4.  
    5. // Consider all the operators that can work with transform.position.x in UnityScript.
    6. // It would be ridiculous to implement them all as extension methods.
    7. public static void TryToBeCoolLikeHippocoderButFail (this Transform transform, float x) {
    8.     Vector3 position = transform.position;
    9.     position.x = x;
    10.     transform.position = position;
    11. }
    12.  
    13. }
    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public class NewBehaviourScript : MonoBehaviour {
    4.  
    5. new Transform transform;
    6.  
    7. void Awake () {
    8.     transform = GetComponent<Transform>();
    9.     transform.TryToBeCoolLikeHippocoderButFail(10);
    10. }
    11.  
    12. }