Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update () {
- //this should make the line, why not working?
- Vector3 forward = transform.forward;
- Debug.DrawRay(transform.position, forward);
- Debug.DrawLine(transform.position, transform.position + forward * 10000);
- if (Input.GetMouseButtonDown (0)) {
- //
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 100.0f)){
- //
- //
- Vector3 startPos = transform.position;
- Vector3 clickPos = new Vector3(hit.point.x, hit.point.y, transform.position.z);
- Vector3 direction = Direction (clickPos - startPos);
- //direction
- rb.velocity = new Vector3(direction.x * 5, direction.y * 5, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement