-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFollowMouse.cs
More file actions
33 lines (31 loc) · 868 Bytes
/
FollowMouse.cs
File metadata and controls
33 lines (31 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using UnityEngine;
using System.Collections;
public class FollowMouse : MonoBehaviour
{
// Use this for initialization
private bool isSafeToPlay = false;
public LayerMask raycastMask;
void Start ()
{
NotificationCenter.DefaultCenter.AddObserver (this, "SafeToPlay");
}
void SafeToPlay ()
{
isSafeToPlay = true;
}
// Update is called once per frame
void FixedUpdate ()
{
if (isSafeToPlay) {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit, 1000.0f, raycastMask)) {
Vector3 onFloor = new Vector3 (hit.point.x, 0.0f, hit.point.z);
//Instantiate (prefab, onFloor, Quaternion.identity);
//MoveShip (onFloor);
transform.position = onFloor;
Debug.DrawLine (ray.origin, onFloor, Color.green);
}
}
}
}