I get this error: Assets/Scripts/AxeAttack.js(41,35): BCE0019: ‘transform’ is not a member of ‘Object’
in this script:
#pragma strict
private var isAttacking : boolean = true;
private var attackCoolDown = 0.0;
var damage = 50;
var range = 5;
private var mainCamera;
function Start () {
isAttacking = false;
mainCamera = GameObject.FindWithTag("MainCamera");
}
function Update () {
if(isAttacking)
{
attackCoolDown += Time.deltaTime;
if(attackCoolDown >= 2)
{
isAttacking = false;
attackCoolDown = 0.0;
}
}
if(Input.GetMouseButtonDown(0) && isAttacking == false)
{
Attack();
}
if(isAttacking == false)
{
this.gameObject.animation["idle_cube"].wrapMode = WrapMode.Loop;
this.gameObject.animation.CrossFade("idle_cube");
}
}
function Attack ()
{
this.gameObject.animation.CrossFade("attack_cube");
isAttacking = true;
attackCoolDown = 1;
var direction = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
Debug.DrawLine(mainCamera.transform.position,direction*range,Color.red);
if (Physics.Raycast (mainCamera.transform.position, direction, hit, range));
{
if(hit.transform.tag == "Enemy")
{
hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
}
}
}
I am pretty new to UnityScript, sorry x)