Constant friction force

About advanced scenes, and the Thyme scripting language used in Algodoo.

Constant friction force

Postby Kilinich » Tue Jan 03, 2012 10:01 pm

It can be very useful for top view games like pool.
It's a script for circles with constant air friction (works with any custom air).

force (in Newtons) is adjusted via _frictionForce variable

Code: Select all
_frictionForce = 1;
airFrictionMult = {
    circle := readable(owner);
    v := circle.vel;
    u2 := (v(0) * v(0) + v(1) * v(1));
    u := u2 ^ 0.50000000;
    d := circle.radius * 2;
    ff := d * (Sim.airFrictionLinear * u + Sim.airFrictionQuadratic * u2);
    ff == 0 ? 1 : {owner._frictionForce / ff / Sim.airFrictionMultiplier}
}


Just put that code into circle's script window and it will behave like a hockey puck ;-)

Rating: rated 5.6
Filesize: 9.37 kB
Comments: 3
Ratings: 2
download
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Constant friction force

Postby davidz40 » Sat Jan 07, 2012 5:51 pm

Great for top view car sims too.
Phundamentalist
User avatar
davidz40
 
Posts: 438
Joined: Sun Sep 06, 2009 10:30 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests