Hey i want to add force to instead of this.gameObject something like that.gameObject . So i add force to the gameobject that is tagged as box if i collide with it. feel free to clean the code if there is something wrong
#pragma strict
var attacking : boolean;
var hasAttacked : boolean;
function Update () {
Attack();
}
function Attack(){
if(Input.GetMouseButtonDown(0))
{
attacking = true;
yield WaitForSeconds(5);
attacking = false;
}
}
function OnTriggerEnter(col : Collider)
{
if(col.collider.tag == "Box" && attacking == true && hasAttacked == false)
{
that.gameObject.rigidbody.AddForce(Vector3.up * 10000);
hasAttacked = true;
}
else if(col.collider.tag == "Enemy")
{
//attack enemy
}
}
function OnTriggerExit(col : Collider)
{
if(col.collider.tag == "Box")
{
hasAttacked = false;
}
else if(col.collider.tag == "Enemy")
{
hasAttacked = false;
}
}