Speed Locking?
8 posts • Page 1 of 1
Speed Locking?
Is there any way to lock an objects speed to a specific direction?
Meaning, if I have an arrow:
-->
And I want it to go only in the direction it is pointing, is there any way to do this?
I would like it to work even if I rotate the arrow, like this:
/\
|
And it will start to move upwards.
Thanks,
--mold999
Meaning, if I have an arrow:
-->
And I want it to go only in the direction it is pointing, is there any way to do this?
I would like it to work even if I rotate the arrow, like this:
/\
|
And it will start to move upwards.
Thanks,
--mold999
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: Speed Locking?
No easy way to do...
But you can try use one of my "wheels" for that:
But you can try use one of my "wheels" for that:
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Speed Locking?
Could you explain a little more about the scene?
Like the n and vn variables in the wheels, and the clamp(). Also the n and s variables in the thrusters.
Thanks,
Like the n and vn variables in the wheels, and the clamp(). Also the n and s variables in the thrusters.
Thanks,
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: Speed Locking?
mold999 wrote:Could you explain a little more about the scene?
Like the n and vn variables in the wheels, and the clamp(). Also the n and s variables in the thrusters.
Code for wheel:
- Code: Select all
v := entity.vel;
n := [ - math.sin(entity.angle), math.cos(entity.angle)];
vn := ((v(0) * n(0) + v(1) * n(1)));
entity.vel = entity.vel - n * clamp(vn, - entity._maxForce, entity._maxForce) * entity._airForceMult;
n - normal direction vector of wheel with length = 1
vn - velocity projection to that normal, means how fast wheel moving in "side" direction
clamp is a build-in function declared in config just a limits for value (x, min, max)
Same for thruster but instead of normal I use forward direction vector. "s" means velocity projection to forward direction, or how fast car movig forward (backward is negative) removing "side" part of velocity.
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Speed Locking?
I was thinking...
Can't I just set the velocity of the arrow to
[Math.sin(angle), Math.cos(angle)]
And multiply by a factor to increase the speed?
I tried it, but it wouldn't work. Is there something I'm doing wrong?
Can't I just set the velocity of the arrow to
[Math.sin(angle), Math.cos(angle)]
And multiply by a factor to increase the speed?
I tried it, but it wouldn't work. Is there something I'm doing wrong?
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: Speed Locking?
My script stops wheel from moving sideways. Did you get it?
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Speed Locking?
Yes, I got it. 
But, why doesn't [Math.sin(angle), Math.cos(angle)] work? Shouldn't that just give the x and y speeds?
But, why doesn't [Math.sin(angle), Math.cos(angle)] work? Shouldn't that just give the x and y speeds?
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: Speed Locking?
mold999 wrote:Yes, I got it.
But, why doesn't [Math.sin(angle), Math.cos(angle)] work? Shouldn't that just give the x and y speeds?
Result is vector pointing to direction of geom's "front"
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
8 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests




