I can't find the syntax manual

The manual used to include the unity .js syntax. It had stuff like the update function and OnTriggerEnter and OnMouseDown.

Drop unity script, and use C#. Check out the MSDN by microsoft.

1 Like

not reallyā€¦ the syntax for what? unityscript? c#? shaders? what functionality are you trying to get at? etc.

Hey big 12345,

JS References:

Unity Script Reference: (Make sure the JS button is selected)

I agree with SubZeroGamingā€™s comment.

-Drew

These links are for ECMAScript (Web) JavaScript and donā€™t apply to Unity.

2 Likes

The ā€œManualā€ section only shows C#, however the Scripting API section allows you to use either or. Look it the upper right hand corner where you can select C# or JS. For example:

Can I ask like a random question?

for something like transform.Translate(1, 1, 1)ā€¦ which is forward, which is right, and which is up

sure

I also canā€™t find operators like say I want to use an if statement with ands and ors and equals or does not equal

Check out my signature for some tutorials.

Neither. itā€™s transform.Translate(x, y, z);
If you want to get the .forward itā€™s a normalized direction that jus tells which direction your model is ā€˜facingā€™, so 0, 1, 0 would mean that youā€™re facing straight up.

Itā€™s the same as C# in that regard:

And - &&
OR - ||
Equals - ==
NotEquals - !=

Q: Where can I find the official UnityScript/JavaScript language reference?
A: It doesnā€™t exist.

Q: How is it possible?
A: :smile:

1 Like

Hey Dustin thanks for the linkā€¦ this is what Iā€™m working on.

http://pastebin.com/TGUNmwU3

I would like to try the best I can to make it work using your linkā€¦ meaning like the official syntax. I have it all as one script but I know it has to be in multiple scripts using different libraries.

Hereā€™s a quick conversion of that file:

using UnityEngine;

public class SomeScript : MonoBehaviour
{
    public GameObject prefab;

    private float Health;
    private bool IsDead;

    private bool HasCorrectItem;

    private Texture Attack1;
    private Texture Attack2;

    private Transform Projectile1;
    private Transform Projectile2;

    private Transform DeadBody;

    private float Probability;

    private Transform transform;

    private void Awake()
    {
        transform = GetComponent<Transform>();
    }

    private void Update()
    {
// for movement
        if (Input.GetKeyDown("w"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("s"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("a"))
            transform.Rotate(0, 0, 0);

        if (Input.GetKeyDown("d"))
            transform.Rotate(0, 0, 0);

        if (Input.GetKeyDown("q"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("e"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("space"))
            transform.Translate(0, 0, 0);

// for animation
        if (Input.GetKeyDown("w"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("s"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("a"))
            transform.Rotate(0, 0, 0);

        if (Input.GetKeyDown("d"))
            transform.Rotate(0, 0, 0);

        if (Input.GetKeyDown("q"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("e"))
            transform.Translate(0, 0, 0);

        if (Input.GetKeyDown("space"))
            transform.Translate(0, 0, 0);

// for health and respawn
        if (Health < 0)
        {
            IsDead = true;
        }

        if (IsDead)
        {
            // transform.location(1, 1, 1)  // No idea what this is                       
            IsDead = false;
        }

// for spawning a dead body
        if (IsDead)
        {
            Instantiate(DeadBody, Instantiate(prefab, new Vector3(i*2.0F, 0, 0), Quaternion.identity);
        }

// for making the dead body have a lootable item based off of probability
    }

    private void OnGUI()
    {
// for the projectiles
        if (GUI.Button(new Rect(10, 70, 50, 30), Attack1))
            Instantiate(Projectile1, Instantiate(prefab, new Vector3(i*2.0F, 0, 0), Quaternion.identity);

        if (GUI.Button(new Rect(10, 70, 50, 30), Attack2) && HasCorrectItem)
            Instantiate(Projectile2, Instantiate(prefab, new Vector3(i*2.0F, 0, 0), Quaternion.identity);

// for an inventory

// for looting the item off the dead body


    }


// for clicking the dead body to change a variable

// for subtracting health
    private void OnTriggerEnter(Collider other)
    {
        if (gameObject.tag == Projectile1.ToString())
        {
            Health -= 1;
        }

        if (gameObject.tag == Projectile2.ToString())
        {
            Health -= 2;
        }
    }
}

Two problems though:

  1. whereā€™s the ā€˜iā€™ thatā€™s used in the methods coming from?
  2. What are you trying to accomplish with the line ā€œtransform.location(1, 1, 1)ā€?

I messed up with where I have transforms for the part where it says // for animationā€¦ I also added something for checking for the correct item which I havenā€™t figured out yet either and is just ā€œ// for checking to see if it has the correct itemā€

http://pastebin.com/qrzx8x82

I have lots of parts where I just have ā€œ// and then an explanationā€ of what I wantā€¦ but that I havenā€™t figured out how to implement it yet.

Documentation for UnityScript doesnā€™t exist. Unity has no plans to create the documentation. Most of the community have switched over to C#. There are some diehard UnityScript users, but their numbers are shrinking.

1 Like

Can someone show me where I can play an animation clip with an if statement?

http://lmgtfy.com/?q=play+animation+clip+site%3Aunity3d.com

1 Like

Thanks again Dustin

How can I use OnMouseDown so that when I click a specific game object it spawns a variable?

Step 1: Click the button
Step 2: Please go through the tutorials and Learn section as this will be a painful and slow process asking one basic question at a time.

2 Likes