Spawn circle in front of a moving one

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

Spawn circle in front of a moving one

Postby Luka » Fri Sep 11, 2015 9:02 pm

I'm trying to spawn a circle in direct front of another one. Here's an illustration of what I'm trying:
Capture.PNG
(7.53 KiB) Not downloaded yet
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Luka
 
Posts: 17
Joined: Wed Oct 23, 2013 12:57 pm
Location: pos[0, 0]

Re: Spawn circle in front of a moving one

Postby T'wind_ » Fri Sep 11, 2015 11:49 pm

I think this will work. Increase the 0.1 to increase the space between.
Code: Select all
_dir := math.atan2(scene.my.p0Vel(1), scene.my.p0Vel(0));
pos := scene.my.p0Pos + [cos(_dir) * (scene.my.p0Radius + 0.1), sin(_dir) * (scene.my.p0Radius + 0.1)]
User avatar
T'wind_
 
Posts: 86
Joined: Wed Jul 08, 2015 5:33 pm
Location: Western Europe

Re: Spawn circle in front of a moving one

Postby Luka » Sat Sep 12, 2015 12:17 pm

Works wery well. Thanks!
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Luka
 
Posts: 17
Joined: Wed Oct 23, 2013 12:57 pm
Location: pos[0, 0]

Re: Spawn circle in front of a moving one

Postby T'wind_ » Sat Sep 12, 2015 12:37 pm

You can also do it this way. Again change the 0.1 to change the space between.
Code: Select all
pos := scene.my.p0Pos + [(scene.my.p0Vel(0)*(scene.my.p0Radius + 0.1))/(scene.my.p0Vel(1)^2+scene.my.p0Vel(0)^2)^0.5,(scene.my.p0Vel(1)*(scene.my.p0Radius+0.1))/(scene.my.p0Vel(1)^2+scene.my.p0Vel(0)^2)^0.5]
User avatar
T'wind_
 
Posts: 86
Joined: Wed Jul 08, 2015 5:33 pm
Location: Western Europe


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests