Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 artificialfool · Jan 24, 2012 at 10:11 PM · crashlerplinerendererinterpolationsmoothing

Linear interpolation crash

I am running the following script which when properly attached to any objects of your choice and running the camera in orthographic mode basically draws smoothed lines on the path where the mouse was whiel mouse1 is held down. It works fine normally but any time I draw a loop with the mouse it crashes unity! any suggestions?

 public var stroke : Transform;

private var toPaint : Array = new Array();

private var u : float;

public var smoothness : float = 0.1;

public var lineholder : GameObject;

private var toDraw : Array = new Array();

private var mousez : int;

private var liner : LineRenderer;

function Start()

{

}

function Update ()

{

 if(Input.GetMouseButton(0))

 {

   

   

      mousePos = Input.mousePosition;

      mousePos.z = 10;

     worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

     transform.position = worldPos;

     transform.position.z = 0;

     

   var pos:Vector3 = transform.position;

   toPaint.push(pos);

   //Debug.Log("mousedown" + toPaint.length);

     

     //var currstroke:Transform = Instantiate(stroke, pos,  Quaternion.identity);

     

     //currstroke.rigidbody.position = this.rigidbody.position;

     

             //Debug.Log(toPaint.length);

    



 }

 else if(toPaint.length != 0)

 {



     var tempHolder : GameObject = Instantiate(lineholder, Vector3.zero, Quaternion.identity);

     liner = tempHolder.AddComponent(LineRenderer);

     

     print("still working");

     for(var x: float = 0.0; x < 1; x += smoothness)

     {

         

         //toDraw.push((Instantiate(stroke, interpol(toPaint, x),  Quaternion.identity)).transform.position);

         toDraw.push(interpol(toPaint, x));

         

     }

     

     liner.SetVertexCount(toDraw.length);

             print("still working2");

     for(var y : int = 0; y < toDraw.length; y++)

     {

         liner.SetPosition(y, toDraw[y]);

     }

     

     toDraw.clear();

     toPaint.clear();

     

 }

}

static function interpol(arr : Array, u : float) : Vector3

{

 if(arr.length == 1)

 { var v : Vector3 = arr[0]; return(v);}

 

 

 var arr1 : Array = new Array();

 var arr2 : Array = new Array();

 if(arr.length > 1)

 {

     for(var x :int = 1; x < arr.length; x++)

     {

         arr1.push(arr[x]);

     }

     for(var y :int = 0; y < arr.length - 1; y++)

     {

         arr2.push(arr[y]);

     }

     

 }



 



 return Vector3.Lerp(interpol(arr1, u), interpol(arr2, u), u);

 



}

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to get a smooth curved line between two points like those present between the nodes of bolt visual scripting. 1 Answer

Crash on loop using Lerp. 1 Answer

Mathf.Lerp is just jumping to maximum, no 5.0 interpolation. 1 Answer

Smoothing noises with different amplitudes (Part 2) 0 Answers

How to interpolate or polyfit two data sets? 0 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