public void OnTriggerEnter2D(Collider2D other)
    {
        Player player = other.GetComponent <Player>();

        if (player == null)
        {
            return;
        }
        PathedProjectile projectile = gameObject.GetComponent <PathedProjectile>();

        if (projectile != null)
        {
            projectile.CreatEffect();
        }

        Debug.Log("Hit Player");
        player.TakeDamage(damageToGive);
        Controller2D controller    = player.GetComponent <Controller2D>();
        Vector2      totalVelocity = (Vector2)player.velocity + velocity;

        ImpactReciever impactReciever = player.GetComponent <ImpactReciever>();
        Vector3        direction      = player.transform.position - transform.position;

        impactReciever.AddImpact(direction, Mathf.Clamp(Mathf.Abs(totalVelocity.magnitude), 10, 20));
    }
Exemplo n.º 2
0
    private IEnumerator RectifyVelocity(CharacterController2D controller, PathedProjectile projectile)
    {
        yield return new WaitForEndOfFrame();

        if (_velocity.sqrMagnitude == 0)
            Parameters.Model = Knockback.KnockBackModel.Constant;

        HandleKnockback(controller);
    }
Exemplo n.º 3
0
    private void Update()
    {
        if ((nextShotInSeconds -= Time.deltaTime) > 0)
        {
            return;
        }
        nextShotInSeconds = fireRate;

        PathedProjectile projectile = (PathedProjectile)Instantiate(Projectile, transform.position, transform.rotation);

        projectile.Initalize(destination, speed);
    }
    // Update is called once per frame
    void Update()
    {
        if ((nextShotInSeconds -= Time.deltaTime) > 0)
        {
            return;
        }
        Animator a = GetComponentInParent <Animator>();

        if (a != null)
        {
            Debug.Log("Play Animation");
            a.SetTrigger("Shoot");
        }
        nextShotInSeconds = fireRate;
        Debug.Log("Shoot");
        PathedProjectile p = (PathedProjectile)Instantiate(projectile, transform.position, transform.rotation);

        p.Initalise(destination, speed);

        if (spawnEffect != null)
        {
            ///Instantiate(spawnEffect, transform.position, transform.rotation);
        }
    }