Question by
justthatrio · Jan 26, 2021 at 04:50 AM ·
raycastpositionwaypointwaypointswaypoint system
what's wrong with my waypoint placer script
so basically i began creating a script that renders waypoints, and when it came down to the part that creates new waypoints in the editor at the mouses position, I've hit pitfalls. there are no errors showing in the console however nothing happens at all when I shift click, here's my code. if someone could point me to whats wrong id greatly appreciate it, for some reason when I ask questions on here nobody ever helps me out
void OnMouseDown()
{
if(Input.GetKey(KeyCode.LeftShift))
{
Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(worldRay, out hitInfo, Mathf.Infinity))
{
if (hitInfo.collider.gameObject != null)
{
GameObject objectPreview ;
objectPreview = new GameObject("testnode");
objectPreview.transform.position = hitInfo.point;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
What is a WaypointCircuit? How I make one? 2 Answers
AI Waypoint rotate problem 0 Answers
Why the loop in waypoints in not working when set to true? 0 Answers
To send Raycasting to four corners ? 1 Answer