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.
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.
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:
Hey Dustin thanks for the linkā¦ this is what Iām working on.
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:
- whereās the āiā thatās used in the methods coming from?
- 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ā
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.
Can someone show me where I can play an animation clip with an if statement?
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.