コード例 #1
0
ファイル: WingInteractible.cs プロジェクト: Nikira/GGJ2020
    public void OnAction(BlobController blob)
    {
        var dir = new Vector3(Input.GetAxis(blob.horizontalCtrl) / 2f, 1f, 0f);
        var vec = (dir).normalized * force;

        blob.GetComponent <Rigidbody2D>().AddForce(vec);
    }
コード例 #2
0
ファイル: BlobController.cs プロジェクト: Nikira/GGJ2020
    public void AddChild(BlobController child, bool createJoint = true)
    {
        GetEveryConnectedBlob().ForEach(blob => blob.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll);
        _children.Add(child);
        child.parent           = this;
        child.transform.parent = transform;
        child.name             = $"{gameObject.name}{children.Count}";

        child.Inherit(this);

        if (createJoint)
        {
            CreateSpring(child.GetComponent <Rigidbody2D>());
        }
        GetEveryConnectedBlob().ForEach(blob => blob.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.None);
    }
コード例 #3
0
ファイル: LegInteractible.cs プロジェクト: Nikira/GGJ2020
    public void OnCollideWithBlob(BlobController other)
    {
        if (picked)
        {
            return;
        }
        other.ParentObject(gameObject);
        var rigidBody = GetComponent <Rigidbody2D>();

        if (rigidBody)
        {
            Destroy(rigidBody);
        }
        var collision = GetComponent <BoxCollider2D>();

        if (collision != null)
        {
            Destroy(collision);
        }

        other.GetComponent <Rigidbody2D>().sharedMaterial = legFriction;
        parent = other;
        picked = true;
    }