Making ball do an ellipse when thrown
beckb
Member Posts: 16
I'd like to make a ball head to a designated point every time, but I'd like for it to do an ellipse while it gets there, kind of like a basketball being thrown to a hoop (but never missing the hoop). Thanks!
Comments
I've made you a quick demo, might give you some pointers.
http://www.mediafire.com/?nmx7a2h1g4ay930
Constrain self.positionx = crazy sin equation
Constrain self.positiony = crazy cos equation
Not sure what these mean (and how gametime is tied into them). Would you mind explaining? Also, is there a simpler way to do this using physics? Thanks a bunch for taking the time to make it.
470*sin(( game.Time *100)-90)+512
470 = radius of the ellipse.
sin(xxxxxxx) = is the sine of angle xxxxxxx
The '*100' speeds it up - it multiplies the angle by 100.
The '-90' puts the start point of 'sin' 90° out of phase - so it starts on the left rather than in the middle.
The 512 shoves the whole equation 512 pixels to the right, so it's centred in the middle of the screen.
Similar deal for Y.
Game.time is simply a rising value (you could use anything you want here) - it is being used as the angle for sin to operate on.
Hope that make some sense !!
. . . . . . . .
I am doing a sin / cos tutorial which might be helpful, but it's not finished yet, but here a stripped out illustration of how sin and cos relate to a circle / ellipse:
http://www.mediafire.com/?f9r4io6a7za8ban
Yeah, if you want to be interactive rather than a fixed path that always arrives at a designated point, then it's best to use a little physics.