how can i make a working slingshot or launchpad script

hey everybody my brother and i are trying to make a game , we worked out everything the player ,the idea … but were still having this problem we can’t find a script to make a slingshot or a launchpad to launch or shoot are player in the direction we want

I’m not going to provide a wonderful script, but I can point you into a direction. For your slingshot, create two empty gameObjects. One will be static, and one will be the ‘pulled part’ of the slingshot, where the object that is launched will be. Put a script on the empty that moves, and try the following:

public GameObject originPosition;
public GameObject objectToLaunch;
public float strength;

void Update() {
	if(Input.GetMouseButtonUp()) {
		transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
		objectToLaunch.GetComponent<RigidBody>().AddForce((originPosition.transform.position - transform.position) * Vector3.Distance(transform.position, originPosition.transform.position) * strength, ForceMode.Impulse);
	}

}

Now I’m sure this won’t work because I usually mess these things up, and it’s untested (written in Notepad++ so I have no idea what happens).

Essentially, it will add force to the object you’re launching in the direction that it should (or the reverse? Just flip some things around), and multiply it by the distance (so it doesn’t go as far when it’s closer) and then by a strength value. Just by looking at it, the strength value should be pretty low, and shouldn’t ever really go above 1. Start with 0.1 and work your way up.

Can you tell me the result of this?