private void createNewAnchor(RaycastHit hit, TetherAnchor prevPoint, float prevangle) { Vector3 hitLocalSpace = hit.transform.InverseTransformPoint(hit.point); Vector2 offset = new Vector2(Mathf.Sign(hitLocalSpace.x), Mathf.Sign(hitLocalSpace.y)); Vector2 newTetherPosition = new Vector2( (offset.x * (hit.transform.localScale.x * 0.5f)) + offset.x * outsideBufferDist, (offset.y * (hit.transform.localScale.y * 0.5f)) + offset.y * outsideBufferDist ); newTetherPosition = hit.transform.TransformPoint(newTetherPosition); tether_points.Push(new TetherAnchor(toVec3(newTetherPosition), prevPoint, prevangle)); }
void Start() { player = gameObject; myRb = player.GetComponent <Rigidbody2D>(); tetherRb = tether.GetComponent <Rigidbody2D>(); tethered = false; healthBar.value = health; transform.position = this.transform.position; TetherAnchor attachPoint = new TetherAnchor(new Vector2(0, 0), null, 0); tether_points = new Stack <TetherAnchor>(); tether_points.Push(attachPoint); autoConnectTimeout = 0.1f; }
public TetherAnchor(Vector2 new_anchorPoint, TetherAnchor new_prevPoint, float new_prevangle) { anchorPoint = new_anchorPoint; previousPoint = new_prevPoint; prevangle = new_prevangle; }