Guest User

Untitled

a guest
Oct 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var prefab: GameObject;
  2. function Update () {
  3. if(Input.GetButtonDown("Fire1")){
  4. var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
  5. var hit :RaycastHit;
  6. if (Physics.Raycast (ray, hit, 100)){
  7. hit.point.z=0.0;
  8. var dir:Vector3=(hit.point-transform.position).normalized;
  9. Debug.Log(hit.point);
  10. var projectile = Instantiate(prefab, transform.position+dir, Quaternion.identity);
  11. projectile.rigidbody.velocity=20*dir;
  12. }
  13. }
  14. }
Add Comment
Please, Sign In to add comment