Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 benfattino · Jul 19, 2011 at 09:23 PM · timepointdraw

Draw point with time function

I try to write a script to draw cloud-point. The script must draw a single point every second from an array (or or a time that I decide). I try to use Time (or delta.Time) function (I search inside forum without result) without result. I don't understand it'work... This is the script:

 var dotMaterial : Material;
 var PointsList : Array;
 var Points : Array;
 var PointsArray : Vector3[];
 var dotSize = 1.0;
 var dotsnumber = 1;
 var dotstime = 1;
 
 private var oldPosition : Vector3;
 private var oldRotation : Quaternion;
 private var cam : Transform;
 private var dots : VectorPoints;
 
 PointsList = [];
 
 function Start() {
     cam = Camera.main.transform;
     oldPosition = cam.position;
     oldRotation = cam.rotation;
 
     Points = new Array();
     for (i = 0; i < PointsList.length / 3; i++){ 
     Points.Add(Vector3(-PointsList[i*3],PointsList[i*3+2],-PointsList[i*3+1]));
     }
     
     PointsArray = Points.ToBuiltin(Vector3);
     dots = new VectorPoints("Dots", PointsArray, null, dotMaterial, dotSize);
     dots.maxDrawIndex = dotsnumber; //this value say how many point of array drawing
     Vector.DrawPoints(dots);
 }
 
 function Update()  { // every second script must be draw one more point
 dotstime = Time.deltaTime*1;
     dotsnumber = dotsnumber + dotstime;
 }
   
 function LateUpdate () {
     if (cam.position != oldPosition || cam.rotation != oldRotation) {
         oldPosition = cam.position;
         oldRotation = cam.rotation;
         dots.maxDrawIndex = dotsnumber;
         Vector.DrawPoints(dots);
     }
  }
Comment
Add comment · Show 3
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
avatar image benfattino · Jul 20, 2011 at 12:47 PM 0
Share

Thanks. The script work, but I have a problem. The frame rate drops over time! Help... This is the new script:

 var dot$$anonymous$$aterial : $$anonymous$$aterial;
 var PointsList : Array;
 var Points : Array;
 var PointsArray : Vector3[];
 var dotSize = 1.0;

 private var oldPosition : Vector3;
 private var oldRotation : Quaternion;
 private var cam : Transform;
 private var dots : VectorPoints;

 PointsList = []; //15000 point coordinate max.
 var dotsnumber = 1;
 
 function Start() {
 InvokeRepeating ("IncreaseDotsnumber", 0.01, 0.01);
     
     Points = new Array();
     for (i = 0; i < PointsList.length / 3; i++){ 
     Points.Add(Vector3(-PointsList[i*3],PointsList[i*3+2],-PointsList[i*3+1]));
     }
     
     RandomizeArray.RandomizeArray (Points);
     PointsArray = Points.ToBuiltin(Vector3);
     dots = new VectorPoints("Dots", PointsArray, null, dot$$anonymous$$aterial, dotSize);
 
 cam = Camera.main.transform;
 oldPosition = cam.position;
 oldRotation = cam.rotation;
 }
 
 function IncreaseDotsnumber(){
 dotsnumber++;
 }
 
 function LateUpdate () {
     
     if (cam.position == oldPosition || cam.rotation == oldRotation){
         dots.maxDrawIndex = dotsnumber;
         Vector.DrawPoints(dots);
         }
     
     else if (cam.position != oldPosition || cam.rotation != oldRotation) {
         oldPosition = cam.position;
         oldRotation = cam.rotation;
         dots.maxDrawIndex = dotsnumber;
         Vector.DrawPoints(dots);
     }
 }
avatar image Eric5h5 · Jul 20, 2011 at 04:59 PM 0
Share

Please don't post comments as answers. It's expected that the framerate would go down over time, since you're drawing more and more of the points over time.

avatar image benfattino · Jul 20, 2011 at 08:20 PM 0
Share

Sorry. It was a question related to the first and I did not want to open another post. Any idea to solve the problem?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Jul 19, 2011 at 09:57 PM

"dotstime" is an int, so assigning Time.deltaTime to it will always result in 0. You're better off just using InvokeRepeating anyway.

 function Start () {
     InvokeRepeating ("IncreaseDotsnumber", 1.0, 1.0);
 }
 
 function IncreaseDotsnumber () {
     dotsnumber++;
 }
Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Timing problem in Guitar Hero style game 2 Answers

How to check if you draw/outline a symblol by its contour? 2 Answers

Draw single point 2 Answers

Draw line from one point to another using mouse 0 Answers

Calculate the distance a object has moved. 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges