Physics question (slingshot)...

Hello. I would like to develop a system that works as follows: the player touches the screen (the reason I am not asking this in the iOS forum is because this is more of a general scripting question…just replace touch position with cursor position, but I digress) to set the anchor point for a slingshot. They then drag downwards and upon removing their finger, the slingshot fires.

The current solution I am prototyping is rather cumbersome. At the initial touch position I spawn an object that has a kinematic rigidbody and a spring joint attached to it. When I detect a position change in their touch, I spawn another object with default rigidbody and set it as the object that the spring in the first object is attatched to. I then have the player’s touch position control the position of the second object (clamping it’s position at the maximum I want the slingshot to stretch). When the user releases their finger, I wait a fraction of a second (so that the second object has started to move upwards), delete the first object and the second objects goes flying.

As I said…cumbersome :roll:
Aside from being difficult to test and control, I’m getting the feeling that this is way more complex than it needs to be. Does anyone have any ideas on how I would get this done in a simplified manner. Thanks

I assume we are talking about an angry birds type slingshot…

there is a hugely simpler method you could use that should work.

First change the rigidbody to not IsKinematic so forces can do all the work.

  1. While the user holding, make the projectile lookat the top of the slingshot. This should give you the angle you need to fire. (Transform.LookAt)
  2. On release, RigidBody.Addforce in the forward

Would love to see a tutorial on this somewhere, I’m trying to accomplish something similar although on a slingshot.