internal void HandleMissileHit(Collision collision) { if (collision.gameObject.tag == "agent" && collision.gameObject != this.gameObject) { TankAgent EnemyHit = collision.rigidbody.GetComponent <TankAgent>(); SetReward(20); //EnemyHit.SetReward(-20); EnemyHit._currentHealth--; if (EnemyHit._currentHealth <= 0) { SetReward(100); // EnemyHit.SetReward(-100); EndEpisode(); } } else if (collision.gameObject.tag == "target") { AddReward(5); Destroy(collision.gameObject); } else { float dist = (collision.GetContact(0).point - transform.position).magnitude; float point = (20f - dist) / 20f; if (point > 0f) { AddReward(point * 5f); //We give points for close hits } } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "enemyTank") { //If the GameObject has the same tag as specified, output this message in the console Debug.Log("Hit enemy!"); owner.HitEnemy(); } if (collision.gameObject.tag == "tankAgent") { //If the GameObject has the same tag as specified, output this message in the console Debug.Log("Hit tank agent!"); owner.HitEnemy(); TankAgent hitTank = collision.gameObject.GetComponent <TankAgent>(); hitTank.TakeDamage(5); } //collision.gameObject.tag != "Untagged" && Destroy(this.gameObject); //wwise event for Collision Collision.Post(gameObject); Debug.Log("Collided with " + collision.gameObject.tag); }
void Start() { agent = gameObject.GetComponent <TankAgent>(); _accelRatePerSec = (MAX_ACCEL - START_ACCEL) / timeToMaxSpeed; specialRatePerSec = MAX_SPECIAL / timeToMAX_SPECIAL; _rb = GetComponent <Rigidbody>(); _tm = GetComponent <ThrusterManager>(); _input = GetComponent <TankInputs>(); CurrentSpeed = START_ACCEL; state = TankState.NORMAL; var transform1 = transform; _initialPos = transform1.position; _initialRot = transform1.rotation; }
public void SetOwner(TankAgent OwnerAgent) { _ownerAgent = OwnerAgent; }
private void Awake() { _ownerTank = GetComponent <TankAgent>(); MissilePref.CreatePool(); }
public void setOwner(GameObject owner_) { owner = owner_.GetComponent(typeof(TankAgent)) as TankAgent; }