Пример #1
0
 void IInteractive.Interact(GameObject interactor)
 {
     if (!frozen)
     {
         AudioSource.PlayClipAtPoint(soundSource, transform.position);
         Character_Base cb = interactor.GetComponent <Character_Base>();
         if (cb != null)
         {
             cb.FlipChar(false);
         }
         face.enabled = false;
         bC2d.enabled = false;
     }
 }
Пример #2
0
    private void Move()
    {
        RaycastHit2D ray = Physics2D.BoxCast(bC2d.bounds.center, bC2d.bounds.size * new Vector2(1, 0.9f), 0f, transform.right * (cB.MoveRight ? 1 : -1), 0.05f, layerMask);

        Color color = Color.green;

        if (ray.collider != null)
        {
            color = Color.red;
            cB.FlipChar(false);
        }

        Debug.DrawRay(bC2d.bounds.center, transform.right * (cB.MoveRight ? 1 : -1) * (bC2d.bounds.extents.x + 0.02f), color);

        moveVelocity = cB.MoveRight ? speed : -speed;
        velocity     = rb2d.velocity;

        //this is here to prevent a bug where the runnor just frezzes at a location
        if (!frozen && velocity.x == 0 && velocity.y == 0)
        {
            transform.position += (transform.up - transform.forward) / 100;
        }
        rb2d.velocity = new Vector2(moveVelocity, velocity.y);
    }