- Home /
Question by
ViniciusVilela · Mar 12, 2017 at 06:11 PM ·
instantiatespawnprojectileslingshot
How can I "reload" a slingshot?
I'm working on a 2D scroller that has an slingshot mechanic (a boat in the main plane shooting at other boats on the background, kinda parallax), but I'm having a few issues on instantiating the projectiles while keeping their Physics and Rigidbody values. I have tried using prefabs, with no success. This is how the slingshot works. Can someone give me any pointers or ideas?
void OnMouseDrag()
{
bola.isKinematic = false;
Vector3 curScreenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 1f);
Vector3 curPosition = Camera.main.ScreenToWorldPoint (curScreenPoint);
transform.position = curPosition;
}
void OnMouseUp ()
{
dir = sling.transform.position - transform.position;
dir = dir.normalized;
bola.AddForce (dir * 1250f);
spring.enabled = false;![alt text][1]
[1]: /storage/temp/89638-potakingunityhelps.png
potakingunityhelps.png
(97.2 kB)
Comment