- Home /
Question by
newtothisstuff · May 15, 2014 at 12:50 AM ·
javascript
Syntax error: Instance required to access non static member
I keep getting this error: Assets/Standard Assets/Character Controllers/Sources/Scripts/MeleeSystem.js(11,40): BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'position'.
#pragma strict
var TheDammage : int = 50;
var Distance : float;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast (Transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
Comment