using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
private SpringJoint2D myLight;
public Vector2 connectedAnchor;
private bool touchingBlock = true;
void Start ()
{
myLight = GetComponent<SpringJoint2D
);
//var object1 = "Block(1)";
}
void Update ()
{
if(Input.GetKeyUp(KeyCode.Space))
{
myLight.enabled = !myLight.enabled;
if (touchingBlock)
Connect();
//connectedAnchor = new Vector2(5.3F,-16.5F);
//myLight.connectedAnchor = connectedAnchor;
}
}
void OnTriggerEnter(Collider other) {
if(other.CompareTag("Player")){
touchingBlock = true;
}
}
void Connect()
{
myLight.enabled = !myLight.enabled;
connectedAnchor = new Vector2(5.3F,-16.5F);
myLight.connectedAnchor = connectedAnchor;
}
}