public void SpawnFromPortal(Vector3 startPosition, Vector3 up)
    {
        GameObject newJoeJeff = Instantiate <GameObject>(crowdEntityPrefab.gameObject, startPosition, Quaternion.Euler(0, Random.value * 360, 0));

        Rigidbody newJeffRigidbody = newJoeJeff.GetComponent <Rigidbody>();

        newJeffRigidbody.detectCollisions = false;

        JoeJeffAgent newJoeJeffAgent = newJoeJeff.GetComponent <JoeJeffAgent>();

        newJoeJeffAgent.Ascend(false); // tell the joejeff he's getting thrown into the air

        Vector3 portalVector = up;

        portalVector.x           += Random.value * 0.2f;
        portalVector.z           += Random.value * 0.2f;
        newJeffRigidbody.velocity = portalVector * respawnVelocity;

        CrowdEntity crowdEntity = newJoeJeff.GetComponent <CrowdEntity>();

        crowdEntity.crowd = this;
        crowd.Add(crowdEntity);

        StartCoroutine(DoEnableJeffCollider(newJeffRigidbody, 0.5f));
    }
示例#2
0
 private void OnTriggerEnter(Collider other)
 {
     if (Mathf.Abs(speed) > killSpeed)
     {
         JoeJeffAgent jj = other.GetComponent <JoeJeffAgent>();
         if (jj != null)
         {
             Vector3 deathVector = body.velocity * 0.6f + Vector3.up * body.velocity.magnitude * 0.3f;
             jj.Die(deathVector, transform.position);
         }
     }
 }
 public static void RegisterJoeJeffDeath(JoeJeffAgent jj)
 {
     OnJoeJeffDeath.Invoke();
 }