Commit c6b62ceb authored by Chrysis248's avatar Chrysis248
Browse files

rope sichtbar beim Ziehen eines Steins

parent 7a85d8c1
...@@ -145,9 +145,10 @@ public class RopeSystem : MonoBehaviour, VariableSoundPlayer.SoundOwner ...@@ -145,9 +145,10 @@ public class RopeSystem : MonoBehaviour, VariableSoundPlayer.SoundOwner
springJoint.enabled = true; springJoint.enabled = true;
springJoint.distance = Vector2.Distance(playerPosition, hit.point); springJoint.distance = Vector2.Distance(playerPosition, hit.point);
springJoint.connectedBody = hit.collider.GetComponentInParent<Rigidbody2D>(); springJoint.connectedBody = hit.collider.GetComponentInParent<Rigidbody2D>();
ropeHingeAnchorSprite.enabled = true;
if (!springJoint.connectedBody.GetComponentInParent<PullableObject>().isHeavy) if (!springJoint.connectedBody.GetComponentInParent<PullableObject>().isHeavy)
{ {
springJoint.connectedBody.gravityScale = 0.4f; springJoint.connectedBody.gravityScale = 1.3f;
} }
} }
else else
...@@ -179,7 +180,7 @@ public class RopeSystem : MonoBehaviour, VariableSoundPlayer.SoundOwner ...@@ -179,7 +180,7 @@ public class RopeSystem : MonoBehaviour, VariableSoundPlayer.SoundOwner
} }
if (springJoint.connectedBody != null) if (springJoint.connectedBody != null)
{ {
springJoint.connectedBody.gravityScale = 1f; springJoint.connectedBody.gravityScale = 20f;
} }
springJoint.enabled = false; springJoint.enabled = false;
springJoint.connectedBody = null; springJoint.connectedBody = null;
...@@ -218,7 +219,15 @@ public class RopeSystem : MonoBehaviour, VariableSoundPlayer.SoundOwner ...@@ -218,7 +219,15 @@ public class RopeSystem : MonoBehaviour, VariableSoundPlayer.SoundOwner
{ {
if (i != ropeRenderer.positionCount - 1) // if not the Last point of line renderer if (i != ropeRenderer.positionCount - 1) // if not the Last point of line renderer
{ {
ropeRenderer.SetPosition(i, ropePositions[i]); if (springJoint.enabled)
{
ropeRenderer.SetPosition(i, ropeHingeAnchor.transform.position);
}
else
{
ropeRenderer.SetPosition(i, ropePositions[i]);
}
// Set the rope anchor to the 2nd to last rope position (where the current hinge/anchor should be) or if only 1 rope position then set that one to anchor point // Set the rope anchor to the 2nd to last rope position (where the current hinge/anchor should be) or if only 1 rope position then set that one to anchor point
if (i == ropePositions.Count - 1 || ropePositions.Count == 1) if (i == ropePositions.Count - 1 || ropePositions.Count == 1)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment