• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by dichterDichter · Feb 22, 2017 at 09:16 AM · updatelinerendererresetarc

reset Line Renderer every second

im drawing an arc which shows me the rotation a gameobject will do. so for example im drawing it from 45° to 135°. Thats working with from/to at start. i would like to update this rotation while im rotating so for example redrawing the arc.

or is there a better way for drawing an arc around a gameobject and update it ? I tried to set the numPositions to 0 but it doesnt work.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class CircleDrawer : MonoBehaviour
 {
     public int segments;
     public float xradius;
     public float yradius;
     LineRenderer line;
 
 
 
     void Start()
     {
         line = gameObject.GetComponent<LineRenderer>();
         line.numPositions = segments + 1;
         line.useWorldSpace = false;
     }
 
     public void ResetLines() {
         line.numPositions = 0;
     }
 
     public void CreatePoints(int from, int to)
     {
         line.numPositions = segments + 1;
 
         float x;
         float y;
         float z = 0f;
 
         float angle = 20f;
 
         int amount = to - from;
 
         transform.localRotation = Quaternion.Euler(90, 160 + from, 0);
 
         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 += (amount / segments);
         }
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Problem: Adding and Subtracting score 1 Answer

Arc line between two objects in world space 2 Answers

how do i make this to a negative (ShopRespawn < 180)? 1 Answer

Get Line Renderer to restart from start everytime using coroutine. HELP?!?!?!? 1 Answer

Scripts won't automatically update, always need to 'reset' them in the inspector for update 11 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges