private void onCollisionEnter(collCtx ctx) { if (this.targetPriority >= ctx.otherType || (ctx.otherType == Type.Minion && this.follower != null)) { return; } this.target = ctx.other; this.otherT = ctx.other.transform; this.targetPriority = ctx.otherType; if (ctx.otherType == Type.Minion) { this.issueEvent <Leader>( (x, y) => x.SetFollower(this), ctx.other); } }
private void onCollisionExit(collCtx ctx) { if (this.target == ctx.other) { Dir moveDir; if (this.targetPriority == Type.Minion) { this.issueEvent <Leader>( (x, y) => x.RemoveFollower(this), ctx.other); } /* The target we were following just left, try to move after it */ this.target = null; this.targetPriority = Type.None; moveDir = vec3ToDir(otherT.position - this.selfT.position); this.StartCoroutine(this.follow(ctx.other, moveDir)); } }