コード例 #1
0
    private void SpawnObject()
    {
        GameObject gameObject = GameObject.Instantiate(spawnObject, parryPosition, Quaternion.identity);
        Directable directable = gameObject.GetComponent <Directable>();

        if (directable != null)
        {
            directable.DirectToward(GetInputDirection());
        }
        hasSpawnedObject = true;
    }
コード例 #2
0
    public void OnHit(Directable other)
    {
        animator.SetBool("IsBouncing", true);
        Vector2 otherDirection = other.GetDirection();
        Vector2 newDirection;

        if (mirrorType == MirrorType.HORIZONTAL)
        {
            // flip the x direction
            newDirection = new Vector2(otherDirection.x * -1, otherDirection.y);
        }
        else
        {
            // flip the y direction
            newDirection = new Vector2(otherDirection.x, otherDirection.y * -1);
        }
        other.DirectToward(newDirection);
    }