walkToAndStop() public method

public walkToAndStop ( Vector2 pos ) : IEnumerator
pos Vector2
return IEnumerator
Esempio n. 1
0
    IEnumerator absorbCharacter(CharacterMove character)
    {
        yield return StartCoroutine(character.walkToAndStop(new Vector2(transform.position.x, character.transform.position.y)));

        myAnimator.SetTrigger("isClosed");
        doorAnimator.SetTrigger("isClosed");

        //Disable this character's collider, so others will walk by.
        character.GetComponent<Collider2D>().enabled = false;
        character.GetComponent<Rigidbody2D>().gravityScale = 0;
        character.GetComponent<Rigidbody2D>().velocity = Vector2.zero;

        //Render the door over the character.
        doorRenderer.sortingLayerName = "Character";
        character.GetComponent<SpriteRenderer>().sortingLayerName = "Pre-Character";

        //Wait for animation to finish.
        yield return new WaitForSeconds(1.5f);

        MasterDriver.levelDriver.saveCharacter(character);

        //Destroy the character, render the door back again.
        DestroyImmediate(character.gameObject);
        doorRenderer.sortingLayerName = "Background Object";

        yield return new WaitForSeconds(1f);

        isTakingCharacter = false;
        yield return null;
    }