Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Username Password: Remember me

Changing Size of Item
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Changing Size of Item

Changing Size of Item 6 years, 1 month ago #703

  • DonDon6
  • OFFLINE
  • Junior Boarder
  • Posts: 30
I am working on some 3D scenes.

I would like to change the size of an item (circle) with the distance along the y axis.

Any suggestion ?

Don

Re: Changing Size of Item 6 years, 1 month ago #704

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
Try this

var circle = world.createCircle(0, 0, 0, 0.25);
circle.OnStart += "this.counter = 0.0;\n";
circle.OnStart += "this.X = 0.0;\n";
circle.OnStart += "this.Y = 0.0;\n";
 
circle.OnUpdate += "this.counter += 0.0001;\n";
circle.OnUpdate += "this.LinearVelocityY = 0.0;\n";
circle.OnUpdate += "var a = Math.sin(this.counter);\n";
circle.OnUpdate += "this.Radius = 0.01 + Math.abs(a);\n";
circle.OnUpdate += "this.X = 4.0 * a;\n";


Writing the snippet above, I noticed that you cannot change world's gravity in "OnStart" event, i.e.
circle.OnStart += "world.GravityY = 0.0;";
won't work

That's why I am using LinearVelocityY to (almost) prevent the ball from falling.

Hope it helps

Re: Changing Size of Item 6 years, 1 month ago #705

  • DonDon6
  • OFFLINE
  • Junior Boarder
  • Posts: 30
Dimitri

Sorry, I am not that proficient in scripting.
I could not figure out how to get it to work.
Could you provide more insturctions (for a beginning scripter) or better yet, send me a working scene.

Don

Re: Changing Size of Item 6 years, 1 month ago #706

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
You'll just need to copy/paste the (first) code snippet in the console and press enter.

You should then start the simulation and see a circle whose radius is changing proportionally to circle's distance from the y-axis.

Re: Changing Size of Item 6 years, 1 month ago #707

  • DonDon6
  • OFFLINE
  • Junior Boarder
  • Posts: 30
See console error I get when I try to run the script. (Attached File)

Don

Re: Changing Size of Item 6 years, 1 month ago #708

  • DonDon6
  • OFFLINE
  • Junior Boarder
  • Posts: 30
SUCCESS - - I got it to work as a script file.

Thanks
  • Page:
  • 1
Moderators: Lynxx, Glenn555
Time to create page: 0.11 seconds