Ejemplo n.º 1
0
 public override void Init(CharacterTemplate chr)
 {
     //var player = FindObjectOfType<PlayerController>().transform;
     //transform.parent = player;
     player = chr.GetComponent <PlayerController>();
     base.Init(chr);
 }
Ejemplo n.º 2
0
 public virtual void Init(CharacterTemplate chr)
 {
     //Debug.DrawRay(chr.transform.position, transform.right,Color.red,2f);
     targetTag          = chr.GetComponent <PlayerController>() ? "Enemy" : "Player";
     transform.position = chr.transform.position + (offset * chr.transform.right);
     direction          = chr.transform.right;
 }
    public override void Init(CharacterTemplate chr)
    {
        var xhit = Physics2D.Raycast(chr.transform.position, chr.transform.right, distanceFromPlayer, 1 << LayerMask.NameToLayer("Ground"));

        if (!xhit)
        {
            var pos = chr.transform.position + chr.transform.right * distanceFromPlayer;

            var yhit = Physics2D.Raycast(pos, -transform.up, maxCastHeight, 1 << LayerMask.NameToLayer("Ground"));
            if (yhit)
            {
                transform.position = new Vector2(pos.x, yhit.transform.position.y);

                direction = transform.up;
                targetTag = chr.GetComponent <PlayerController>() ? "Enemy" : "Player";
            }
            else
            {
                Destroy(gameObject);
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 4
0
 // useful
 public static void immobilize(CharacterTemplate chr)
 {
     chr.GetComponent <Rigidbody2D>().velocity     = Vector3.zero;
     chr.GetComponent <CharacterTemplate>().Mobile = false;
     chr.Idle();
 }