Show speeds in text (question)
12 posts • Page 1 of 1
Show speeds in text (question)
Hello, I need your help! 
I'd like that, in the text of a box, we could see the speed of an object.
Example : I spawn two boxes, one of them with the text "Speed = xxx m/s". If I drag the other box, in the velocities of this one, you'll see an xxx m/s. I'd like to see the same speed in the box with the text.
Could you help me? What do I have to write?
Thanks! (Sorry if I don't explain myself well...)
I'd like that, in the text of a box, we could see the speed of an object.
Example : I spawn two boxes, one of them with the text "Speed = xxx m/s". If I drag the other box, in the velocities of this one, you'll see an xxx m/s. I'd like to see the same speed in the box with the text.
Could you help me? What do I have to write?
Thanks! (Sorry if I don't explain myself well...)
- Thooto
- Posts: 45
- Joined: Sat Mar 26, 2011 2:02 pm
Re: Show speeds in text (question)
How i would do it is... Get kilinich's k-probe laser edition, stick it on the object you want to measure the velocity of, get the box you want to read the text of, and put a laser with maxrays 0 on it, and make it semi-transparent (the box) and in the lasers' onlaser hit put:
Of course there are other ways, but i don't know where you're going to use it.
- Code: Select all
(e)=>{e.geom.text = "'" + (scene.my.k1vel(0) + scene.my.k1vel(1)) + "'"}
Of course there are other ways, but i don't know where you're going to use it.
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: Show speeds in text (question)
Thank you it works! But it will be great if there was something more simple! 
But maybe if I create a simple scene, you'll understand what I want.
But maybe if I create a simple scene, you'll understand what I want.
Last edited by Thooto on Fri Apr 29, 2011 11:21 pm, edited 1 time in total.
- Thooto
- Posts: 45
- Joined: Sat Mar 26, 2011 2:02 pm
Re: Show speeds in text (question)
- Code: Select all
textureMatrix=[e.pos(0)-textureMatrix(2), e.pos(1)-textureMatrix(3), e.pos(0), e.pos(1),(textureMatrix(0)^2+textureMatrix(1)^2)^0.5, 0.0, 0.0, 0.0, 0.0];
Anyway, put an alternating collider (let me know if you don't know what that is) on the second box. In that box's onCollide, put the above velocity code, followed by the following:
- Code: Select all
scene.my.speed = textureMatrix(4) * 50
First, you will have to declare scene.my.speed = 0 in the console (F11).
Then, in the first box, in the script menu, in the text space, put {"" + scene.my.speed}.
That's how I would do it.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Show speeds in text (question)
Ok thanks I'll try this. And, yes, I don't know what an alternating collider is... Could you explain me? 
Edit : I found another way with laser, etc...Now it works, with the codes you gave me! Thank you!
Edit : I found another way with laser, etc...Now it works, with the codes you gave me! Thank you!
- Thooto
- Posts: 45
- Joined: Sat Mar 26, 2011 2:02 pm
Re: Show speeds in text (question)
An alternating collider is better than a laser for this application, for it gives exactly 50Hz.
Okay.
Make two boxes, with some space in between.
Put a circle between the boxes, overlapping both, but only a bit. More overlap means more shock resistance, but also more vibration.
Fixate the boxes to the background, center hinge the circle.
In the Collision menu for all three parts, check the No Self Collision box. This will in the future be referred to as putting the parts on heteroCollide.
Make one of the boxes not collide with water.
In the onCollide of the circle, put this code:
This has the effect of making the circle collide with one of the boxes. During that collision, the circle changes its collideWater, which in turn makes it collide with the other box, where the precess repeats. Hence, "alternating collider".
Okay.
Make two boxes, with some space in between.
Put a circle between the boxes, overlapping both, but only a bit. More overlap means more shock resistance, but also more vibration.
Fixate the boxes to the background, center hinge the circle.
In the Collision menu for all three parts, check the No Self Collision box. This will in the future be referred to as putting the parts on heteroCollide.
Make one of the boxes not collide with water.
In the onCollide of the circle, put this code:
- Code: Select all
collideWater = ! collideWater
This has the effect of making the circle collide with one of the boxes. During that collision, the circle changes its collideWater, which in turn makes it collide with the other box, where the precess repeats. Hence, "alternating collider".
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Show speeds in text (question)
Ok thanks! I think I've understand the system. In fact, that's a refreshing system of the position, it calculates the difference of position into the two times where it's collided, then it converts it to a speed. Am I right?
- Thooto
- Posts: 45
- Joined: Sat Mar 26, 2011 2:02 pm
Re: Show speeds in text (question)
- Code: Select all
textureMatrix=[Difference between current horizontal pos and previous horizontal pos, proportional to the horizontal velocity in m/s,
Same as textureMatrix(0), but vertical,
Previous horizontal pos,
Previous vertical pos,
Speed generated from what some consider the single most famous equation of all-time, that of Pythagoras,
placeholder,
placeholder,
placeholder,
placeholder]
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Show speeds in text (question)
Thats my "get speed script":
- scene.my.speed_box1 returns the actual speed of the object in m/s. You have to point with a laser on it
- scene.my.speed_kmh_box1 returns the actual speed in km/s
- timed and posd are the differences of time and position to the last measurement. Then simply v=ds/dt
- scene.my.speed_box1 returns the actual speed of the object in m/s. You have to point with a laser on it
- scene.my.speed_kmh_box1 returns the actual speed in km/s
- timed and posd are the differences of time and position to the last measurement. Then simply v=ds/dt
- Code: Select all
(e)=>{
scene.my.timed_box1 = app.time - scene.my.time_box1;
scene.my.posd_box1 = scene.my.posx_box1 - e.pos(0);
scene.my.speed_box1 = scene.my.posd_box1 / scene.my.timed_box1;
scene.my.speed_kmh_box1 = scene.my.speed_box1 * 3.6;
scene.my.time_box1 = app.time;
scene.my.posx_box1 = e.pos(0);
}
-

SyntaxError - Posts: 11
- Joined: Sat Apr 30, 2011 9:00 pm
Re: Show speeds in text (question)
App.time does not do anything. Instead, you want sim.time or system.time. Sim.time is how long the simulation has been running (in seconds), system.time is how ling the application has been running.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Show speeds in text (question)
app.time = sim.time
just try it!
just try it!
-

SyntaxError - Posts: 11
- Joined: Sat Apr 30, 2011 9:00 pm
12 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests




