Skip to content

Instantly share code, notes, and snippets.

@partiallyblind
Created February 18, 2022 11:25
Show Gist options
  • Save partiallyblind/24739521b0f8bdd33703fe1c5595a0eb to your computer and use it in GitHub Desktop.
Save partiallyblind/24739521b0f8bdd33703fe1c5595a0eb to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class ClickSetPosition : MonoBehaviour
{
public PropertiesAndCoroutines coroutineScript;
void OnMouseDown ()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
Physics.Raycast(ray, out hit);
if(hit.collider.gameObject == gameObject)
{
Vector3 newTarget = hit.point + new Vector3(0, 0.5f, 0);
coroutineScript.Target = newTarget;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment