To further explain the error, position is an instance variable (it's a property, but Unity does not distinguish the difference in js) so you must have an instance of a Transform to access that variable.
You treated it like a class variable, meaning you can access without an instance of the object, hence, it outputted the "non-static member".
To solve the problem, you simply need to find an instance in the scene. Creating a new Transform programmatically unattached to a GameObject would be a bad idea. So, using various methods, you must find a transform, then you can say transform.position.
For example:
function Update () {
if(Input.GetButtonDown("Jump"))
{
var Bullet : GameObject = Instantiate (BulletPrefab, GameObject.Find("Spawn").transform.position, UnityEngine.Quaternion.identity);
}
}
In javascript, Unity also includes `using UnityEngine;` automatically so you do not have to reference the namespace when you access the class.
I am unsure how familiar you are with class vs. instance methods and functions so I might recommend reading some tutorials on programming concepts if you are new.
Right I have a slight problem: I tried both of the above and I have tried and tried her is what my script looks like now.
var speed = 3.0;
var rotateSpeed = 3.0;
function Update (){
var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
if(Input.GetButtonDown("Jump"))
{
Instantiate (GameObject.Find("FireBall"),
GameObject.Find("Spawn").transform.position,
Quaternion.identity);
}
}
Here are the errors I get
UnityException: You are not allowed to
call this function when declaring a
variable. Move it to the line after
without a variable declaration. If you
are using C# don't use this function
in the constructor or field
initializers, Instead move
initialization to the Awake or Start
function. Worm..ctor () (at
Assets/Scripts/Worm.js:3)