Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / rolling fast

Author
Message
Todeswalzer
14
Years of Service
User Offline
Joined: 13th Apr 2010
Location:
Posted: 3rd May 2010 17:55
Ok i know this question has been asked a million times before, but i need to make a rolling ball, that slows when you left go of a direction button, everything i have read says "use dark physics" which i have... i've only just got it and have no idea how it works i looked at demo files and such but it just confuzes me, i also have a version of EZrotate, a "Lite" version as far as i can tell, but again, i don't know how it works, i've looked at the 1 demo that came with EZrotate and couldn't make head nor tail of it. Maybe just an explaination or a suggestion of commands that i might use would be really helpful

ta
T
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 3rd May 2010 20:49 Edited at: 4th May 2010 04:10
You don't actually need a plug-in to do what you want to do, but they do make the rotational angles side of things easier.

In a nutshell, when the ball is rolling, you are increasing one of the angles of the object by a certain amount (let's call it Speed as the angle value relates directly to the ball's rolling speed).

At the moment, I assume that Speed is fixed and is being applied when you press a directional key. When you release the key, you don't add anything. So, when you release the key it stops dead.

Instead of this, what you should do is have an acceleration variable (which we will call Accell#) and set it to a very small value - like 0.001.

Make Speed a float variable by using Speed# and set it at 0.0 at the start.

Then, when you press a direction key, you add the Accell# variable to the Speed# variable then apply it by adding Speed# to the current angle of the object. This will result in the ball starting to roll slowly and accelerate.

When you are not pressing a key, you just need to check to see if Speed# is greater than 0.0. ONLY if it is greater, you subtract Accell# from it before applying it - by adding Speed# to the current angle of the object.

This will cause the ball to slowly roll to a halt.

TDK

Todeswalzer
14
Years of Service
User Offline
Joined: 13th Apr 2010
Location:
Posted: 3rd May 2010 21:54
Thank you so much.. that is the simplest answer i have seen so far, and that was pretty much what i was looking for thanks
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 3rd May 2010 22:17
I been having the same trouble, but I don't quite understand what you mean, you have like Speed#+Accell#? how do you apply that to an angle? and how would that make it move?

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th May 2010 00:22 Edited at: 4th May 2010 04:18
Quote: "how do you apply that to an angle? "


When you rotate any object, you get the current angle of the axis you want to rotate about and add a value. Continue adding that value and the object will rotate.

If it's a fixed value, it will instantly rotate while the given key is pressed and instantly stop when the key is released. Using the method above, Speed# is used as the amount to increment the object's angle and starts at 0.0.

When the Accell# variable is continuously added to it (ie when the key is pressed), the value of Speed# slowly increases and the object rotates a little bit more each time - until it reaches the required top speed (which would be capped at the required value).

What you see is rotation which slowly gathers speed. Slowing down is simply the reverse.

[Edit] Having re-read my last post I can see how it might have sounded a little confusing so I re-worded it to make it more understandable.

Quote: "and how would that make it move?"


It wouldn't make it move - I was just explaining the principle of the acceleration (rolling) side of things. You would have to apply the same method to the movement too.



There's no reason why you couldn't also use the value of Speed# to move the ball if you wanted to.

TDK

Login to post a reply

Server time is: 2024-11-23 17:28:51
Your offset time is: 2024-11-23 17:28:51