Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. void Update () {
  2.  
  3. //this should make the line, why not working?
  4. Vector3 forward = transform.forward;
  5. Debug.DrawRay(transform.position, forward);
  6. Debug.DrawLine(transform.position, transform.position + forward * 10000);
  7.  
  8.  
  9. if (Input.GetMouseButtonDown (0)) {
  10.  
  11. //
  12. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  13. RaycastHit hit;
  14.  
  15. if (Physics.Raycast(ray, out hit, 100.0f)){
  16.  
  17. //
  18.  
  19.  
  20. //
  21. Vector3 startPos = transform.position;
  22. Vector3 clickPos = new Vector3(hit.point.x, hit.point.y, transform.position.z);
  23. Vector3 direction = Direction (clickPos - startPos);
  24.  
  25. //direction
  26. rb.velocity = new Vector3(direction.x * 5, direction.y * 5, 0);
  27.  
  28.  
  29. }
  30.  
  31.  
  32.  
  33. }
  34.  
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement