Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Creating your own scripting language in Unity?

Discussion in 'General Discussion' started by k1mset, Dec 30, 2014.

  1. k1mset

    k1mset

    Joined:
    Dec 4, 2012
    Posts:
    64
    Note: All of this is hypothesised, I am not a fluent JavaScript / C# programmer. Since this isn't actually scripting, I wasn't sure if it should be in the Scripting section, or the Game Design. However, for whatever reason I keep getting a error when trying to start a new thread in the Scripting section.

    Is this possible?

    I came over here from another game engine that used a very easy scripting language to function on, but in the backround was developed by the original languages code. Could essentially this be recreated in JScript / C#? I am sure it can, I am just wondering how exactly.
    I think, just my thoughts rambling, you could develop one massive script in Java (or C#) and call all the functions in another script that would reduce the total time needed to program say, AI for example.

    Example: (not actual code)

    NewLanguage.js
    function SetTargetDestination(gameObject, vector3(X,Y,Z)) {
    // insert code that would take the gameobject that is sent to it frm another script, and the xyz cords and send the object to the xyz cords on a path according to the gameobjects set attribute: moveSpeed
    }

    SetDestination.js
    @scriptinclude NewLanguage.js

    var targetAI : gameObject;
    var targetX : float = 0;
    var targetY : float = 0;
    var targetZ : float = 0;

    function Start {
    SetTargetDestination(targetAI.gameObject,targetX.float,targetY.float,targetZ.float)
    }

    Would this be possible? If so how exactly? Thank you for your time.
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,613
    If I've understood what you're describing correctly: Sure, you can create your own 'library' of useful code that does stuff like this. My UnityScript is a little rusty but I think you'd do something like this:

    Code (csharp):
    1.  
    2. class AIHelpers
    3. {
    4.    static function SetTargetDestination(agent : GameObject, xPos : float, yPos : float, zPos : float) : void
    5.    {
    6.       // do whatever you need to do to set the agent going
    7.    }
    8. }
    9.  
    You'd put that in 'AIHelpers.js.' Then in other scripts you'd just do:

    Code (csharp):
    1.  
    2. function Start()
    3. {
    4.     AIHelpers.SetTargetDestination(targetAI, targetX, targetY, targetZ);
    5. }
    6.  
     
  3. k1mset

    k1mset

    Joined:
    Dec 4, 2012
    Posts:
    64
    Yes I think that is what I am talking about, thank you very much. Does anyone know of a currently exsisting asset that does this?
     
  4. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,973
    I would say the best asset to do what superpig outlined would be a text editor.

    I get the feeling I'm misunderstanding your question though, so... have you checked into Playmaker? It lets you do a bunch of cool stuff without any coding at all, but if you do want to code, you can write actions to work with it, and they are all contained in the Playmaker library, ready to use. That might be close to what you're looking for.
     
  5. k1mset

    k1mset

    Joined:
    Dec 4, 2012
    Posts:
    64
    I will look into it as a possible solution to what I am thinking of. Thank you.
     
    Ony likes this.