What i mean is that from the camera that the view is from the top i want to rotate the circle so it looks like the circle is on the ground. Not to rotate or change the camera position but to rotate the circle i think on the Z axis ?
This is how it looks like from the top view:
And the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawCircle : MonoBehaviour
{
public int segments;
public float xradius;
public float yradius;
LineRenderer line;
void Start()
{
line = gameObject.GetComponent<LineRenderer>();
line.positionCount = segments + 1;
line.useWorldSpace = false;
CreatePoints();
}
private void Update()
{
if (Input.GetAxis("Mouse X") < 0)
{
xradius = xradius + 5;
CreatePoints();
}
if (Input.GetAxis("Mouse X") > 0)
{
xradius = xradius - 5;
CreatePoints();
}
}
void CreatePoints()
{
float x;
float y;
float z = 0f;
float angle = 20f;
for (int i = 0; i < (segments + 1); i++)
{
x = Mathf.Sin(Mathf.Deg2Rad * angle) * xradius;
y = Mathf.Cos(Mathf.Deg2Rad * angle) * yradius;
line.SetPosition(i, new Vector3(x, y, z));
angle += (360f / segments);
}
}
}
I want to rotate the circle so it looks like it was drawing on the terrain.
Maybe i should use somehow Ray and draw the circle already on the terrain ?
But not sure how to use it with my code:
RaycastHit hit;
Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 1000))
{
Vector3 hitpoint = hit.point;
It’s better if i could make the circle to be drawn on the terrain it self and then using the mouse with the ray to change the xradius +5 and - 5