Guest User

Untitled

a guest
Dec 7th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. void Mad() {
  2.  
  3. float rocketSpeed = 2000;
  4. Rigidbody2D bulletInstance = Instantiate(rocket, transform.position, Quaternion.Euler(new Vector3(0, 0, 0))) as Rigidbody2D;
  5. Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
  6. Vector3 dir = Input.mousePosition - pos;
  7. bulletInstance.transform.LookAt(dir);
  8.  
  9.  
  10.  
  11. myRigidbody = GetComponent<Rigidbody2D>();
  12. myRigidbody.AddForce(bulletInstance.transform.forward * rocketSpeed);
Add Comment
Please, Sign In to add comment