- Home /
Why is my cursor not moving with the updating position of the raycast hit point?
Here's the code I'm using:
public GameObject teleportCursor;
void Update()
{
if (OVRInput.Get(OVRInput.Button.PrimaryThumbstick) || Input.GetMouseButton(1))
{
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit, 1000))
{
if (canInstantiateTeleporterCursor == true)
{
Instantiate(teleportCursor, hit.point, Quaternion.identity);
canInstantiateTeleporterCursor = false;
}
teleportCursor.transform.position = new Vector3(hit.point.x, hit.point.y, hit.point.z);
}
}
}
The cursor object is created where the raycast first hits when I first press the button, but it doesn't move with the raycast hit point as it's being updated based on where I am currently pointing while continuing to hold down the button.
Any ideas how to make it constantly move to where I'm pointing using the hit point (which debug tells me is definitely updating each frame/cycle based on where I'm pointing while holding down the button)?
Comment