2
\$\begingroup\$
private void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.blue;

        for (int i = 0; i < waypoints.Length; i++)
        {
            Gizmos.DrawLine(transform.position, target.position);
        }
    }

Before that i'm not sure how to draw at all between all the waypoints.

Instead line maybe to draw spheres or something else and scale it to dots/points ? And i also want to be able to set and change the number of dots/points between each two waypoints.

For example from waypoints[0] to waypoint[1] to draw 30 dots and from waypoints[1] to waypoints[2] 10 dots or just the same maount of dots between all waypoints.

For not not curves lines only straight lines like showing the path between the waypoints in game view.

\$\endgroup\$
  • \$\begingroup\$ It sounds like you already have a theory about how to do this: drawing small spheres at evenly spaced positions between each pair of waypoints. Have you tried putting this theory into practice? \$\endgroup\$ – DMGregory Nov 19 '17 at 14:12
  • \$\begingroup\$ But how do i draw multiple spheres ? If i'm doing for example: for (int i = 0; i < 10; i++) and then: Gizmos.DrawSphere(new Vector3(waypoints[0].transform.position.x * 5, waypoints[0].transform.position.y, waypoints[0].transform.position.z), 0.3f); it will draw one sphere just will change it's position and not draw 10 spheres. \$\endgroup\$ – Daniel Lip Nov 19 '17 at 15:25
  • \$\begingroup\$ Are you literally drawing the sphere at waypoint[0] every time, not waypoint[i]? \$\endgroup\$ – DMGregory Nov 19 '17 at 15:29
  • \$\begingroup\$ Yes at waypoints[0] it was just for testing i wanted to draw for testing 10 sphers from waypoints[0] on x every 5 space. So i did * 5 but it's just changing the sphere position not drawing 10 spheres. Before that i was literally over the waypoints[i] and i did draw spheres on each waypoint but not sure how to draw more spheres between them like a path route. \$\endgroup\$ – Daniel Lip Nov 19 '17 at 15:33
  • \$\begingroup\$ Well, you made a sphere for each waypoint by looping over the waypoints. Could you not make a sphere for each point in between by adding a second loop? ;) \$\endgroup\$ – DMGregory Nov 19 '17 at 15:35
3
\$\begingroup\$

If you found methods such as DrawLine, then you would find more methods on the Gizmos API, such as DrawWireSphere and DrawSphere. You should always consult Unity's API.

To draw lines between each waypoint, it's easy, the number of lines, or intermediates of a number of waypoints its always (the number of waypoints) - 1, so you cando something like this:

for(int i = 0; i < _waypointsQuantity; i++)
    {
        for(int j = (i + 1); j < _waypointsQuantity; j++)
        {
            Gizmos.DrawLine(_waypointsPositions[i], _waypointsPositions[j]);
        }
    }
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

I agree with @LinkWindcrafter. Just the other way around. As you need to draw dots, relatively close to spheres.

float radiusOfDot = 0.1f;
//if you want to add spacing, just iterate i = i+2
for(int i = 0; i < _waypointsQuantity; i++) 
{
    Gizmos.color = Color.yellow;
    Gizmos.DrawSphere(_waypointsPositions[i], radiusOfDot );
}
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.