How can I trigger a gun with pyisics...

I’ve been thinking about this for a lot of time. And a lot of internet search got me nowhere. So here is the thing.

I’m making a game where there is a gun. Which must be shot when a force is being applyed to the actual trigger. It’s supposed to work only when the tirgger is being pulled down or backwards by a rope. I made the rope with HingeJoints2D.

The Gun has a Rigidbody2D attached to it, but all the movement is constrained as it shouldn’t move for the player to be able to make the trap.

I’m really stuck with this. So if anyone can think of a solution to this or maybe had to do something simmilar previously and can share with me how he/she did it…

Thanks in advance

Ok. After a night of sleep and my mind OFF this project I did it.

This is how I acommplished it:

First I created an actual trigger (just a stick, the artist will get the actual draw later I suppose) and added a HingeJoint2D to the object.

I applied limits to the Joint so it wouldn’t go away from it’s position. And then in a script I put this:

	public Lazer gun;

	private Transform myTransform;


	void Start () {

		
		myTransform = this.GetComponent<Transform> ();
	
	}
	
	
	void Update () {

		if (myTransform.rotation.z < 10) 
		{
			ShootLazer();
		}
	
	}


	void ShootLazer()
	{
		gun.Shoot ();
	}

There is probably a better way to do this, but I’m running short on time here… so…