measure speed?

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

measure speed?

Postby jessebax129 » Fri May 21, 2010 6:41 pm

hi i wanna make a car with an speed-meter:
i wanna calculate it with lasers (prefer 1 but 2 is also good or more :P) but does anyone know how to do this?
jessebax129
 
Posts: 34
Joined: Tue Jan 05, 2010 6:32 pm

Re: measure speed?

Postby KarateBrot » Fri May 21, 2010 10:34 pm

declare one or two new variables to save specific position and time values. for example scene.my.time and scene.my.pos. in addition make a variable that saves your velocity values. for example scene.my.vel. then make a laser colliding with a box and in the onhitbylaser scripting line type in:
Code: Select all
(e)=>{ scene.my.vel = (e.pos - scene.my.pos)/(sim.time - scene.my.time); scene.my.pos = e.pos; scene.my.time = sim.time }
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: measure speed?

Postby Kilinich » Fri May 21, 2010 11:14 pm

jessebax129 wrote:hi i wanna make a car with an speed-meter:
i wanna calculate it with lasers (prefer 1 but 2 is also good or more :P) but does anyone know how to do this?


Rating: rated 8.1
Filesize: 19.49 kB
Comments: 19
Ratings: 13
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


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests

cron