Browse Search Popular Register Upload Rules User list Login:
Search:
Asking for help, again...

Image:
screenshot of the scene

Author: AveragePerson

Group: Default

Filesize: 29.27 kB

Date added: 2017-09-17

Rating: 5

Downloads: 110

Views: 183

Comments: 9

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

Ok, so my last save asking for help was a bit complicated I feel, so this is me asking the same question again, but without all the detail, here's the question I need answered: How would I go about scripting "if velocity is more than X, change velocity to X?

If anyone knows how I would do this, please tell me! :)
Thank you.
Please log in to rate this scene
edit
sorry but I don't know:(
postStep = (e)=>{
vel(1) < -0.5 ? {
vel = [vel(0), -0.5]
} : {
vel(1) > 0.5 ? {
vel = [vel(0), 0.5]
} : {}
}
}

Explanation -- Velocity is an array composed of two elements: An X velocity and a Y velocity. Each element defines the speed and the direction of the object. For example, vel = [5.0, -7.0] means move the object to the RIGHT at 5.0 meters per second, and move it DOWN at 7.0 meters per second. The resulting trajectory will be a blend of both the X and the Y velocities (a sloping line in this example).

In the script shown above, this is what it does:

Is the object Y velocity moving down faster than 0.5 M/S? If it is, then force the Y velocity to be -0.5 M/S. Leave the X velocity as it was. If not, then is the object Y velocity moving UP faster than 0.5 M/S? If it is, then force the Y velocity to be 0.5 M/S. Again, leave the X velocity as it was.

Hope this helps!
Last edited at 2017/09/17 17:00:00 by Xray
Is there a way i would be able to make it work for the X velocity aswell? ANd if so, can i get them both to run at the same time?
Yes, the X velocity is vel(0) and the Y velocity is vel(1). Just do the same thing for X as I showed you for Y, but you have to test their current velocities individually. As far as I know, there is no easier way to do it.
Ok, I tried changing the vel(0) to vel(1) and vel(1) to vel (0), but nothing happens. it just dosent have an effect, do i need to do this differently? (sorry if im being dumb, i literally have no talents in scripting in this game)
ok, I changed vel(0) to vel(1) and vel(1) to vel(0), but that didn't work, do i need to do this differently?
Why would you want to change vel(0) to vel(1)? I don't know what that would do, if anything that makes any sense.

But, I'll tell you what I will do for you. I will create and post a scene which drops a box that has a script which limits the Y velocity. That way you could take a look at the script to see what I did. I title it "for AveragePerson". I'll try to get it posted within a couple of hours from now. First I have to feed my dog, and my wife is yelling, I mean asking me to feed her dog. :lol:
Nevermind, i figured it out...thank you very much for helping me though!:)
You're welcome! :tup: