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); }
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); }
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; }