how can I make a curveball (baseball) ?

goonergooner Lancaster, PAMember Posts: 135
edited November 2016 in Working with GS (Mac)

1) i have an actor spawn from top of screen with negative Y linear velocity for the baseball
2) this ball is "pitched" downward toward Y pos 0 (bottom of screen)
.. this works fine

i would now like the ball to start curving as it travels downward toward "home plate"

i've tried change X pos and interpolate X pos but nothing happens with the incorrect way i am attempting this.

any idea of what i could change to create the effect of curving last second at home plate?

thanks! and always appreciate any feedback.

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2016

    _i would now like the ball to start curving . . . _

    This could mean a whole bunch of things, can you be any more specific ? Maybe a quick sketch of the ball's path would help.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited November 2016

    @ellison

    since you use linear velocity, you can do the same in the x direction.

    constrain: self.Motion.Linear Velocity.X = 0.01*pow(1.012,(sceneheight-self.position.Y))

    Play around with the values for the right feel.

    Changing the first (0.01) value sets how soon or how late the curving starts.
    The second (1.012) changes the "strength" of the curve.

    Be careful, small changes have a drastic effect.

  • goonergooner Lancaster, PAMember Posts: 135

    @Socks said:
    _i would now like the ball to start curving . . . _

    This could mean a whole bunch of things, can you be any more specific ? Maybe a quick sketch of the ball's path would help.

    best image i can think of would be the atari logo ... the three lines would show the path of three different pitches (curve left, straight, curve right)

    i am trying to do curve right and curve left

    thanks!

  • goonergooner Lancaster, PAMember Posts: 135
    edited November 2016

    @Hopscotch said:
    @ellison

    since you use linear velocity, you can do the same in the x direction.

    constrain: self.Motion.Linear Velocity.X = 0.01*pow(1.012,(sceneheight-self.position.Y))

    Play around with the values for the right feel.

    Changing the first (0.01) value sets how soon or how late the curving starts.
    The second (1.012) changes the "strength" of the curve.

    Be careful, small changes have a drastic effect.

    wow, this is impressive, thanks!!!

    i was able to get the curve to happen but it starts to curve too late and the arc is too drastic, when i change the values, it doesn't curve at all (so yeah i messed something up)

    i would like the ball to start curving around halfway down and to end up in a set area (between center of screen - 100 and center of screen +100) which is X Pos 284 thru 484. Would there be a change to the formula if I know i want it to end up between X Pos 284 and 484?

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited November 2016

    @ellison

    did you see the project I posted here?

    http://forums.gamesalad.com/discussion/comment/589837/#Comment_589837

    You can visually play around with the curve to get the values. In your case just swap the X and Y values to get the vertical effect.

    Once you have the values you want, you can even introduce a bit of randomness on the B value.

    To randomly change the direction between left and right, multiply the A value by (random(0,1)*2-1)

  • goonergooner Lancaster, PAMember Posts: 135

    @Hopscotch said:
    @ellison

    did you see the project I posted here?

    http://forums.gamesalad.com/discussion/comment/589837/#Comment_589837

    You can visually play around with the curve to get the values. In your case just swap the X and Y values to get the vertical effect.

    Once you have the values you want, you can even introduce a bit of randomness on the B value.

    To randomly change the direction between left and right, multiply the A value by (random(0,1)*2-1)

    great! thank you... i will be trying it out later

  • goonergooner Lancaster, PAMember Posts: 135

    @Hopscotch ... OK I tried this but I still am not getting it yet.

    I downloaded project from the thread and adjusted the points to get the curve I need.

    point A was around .14
    point B was better around 1.01 or less

    I have Position X = 384+point A * pow(point B, position Y - 384)

    This is making it start out wide and curve inward and go straight down to bottom center of the screen.

    I do not understand it enough yet to make changes and/or figure out which part I have reversed improperly. By looking at my example can you see anything I need to move around or flip?

    Thanks!

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @ellison try this project.

    It is probably close to what you want, also in portrait mode.

    In the ball actor is a "Spread" attribute which you can play with, to adjust the curve.

  • goonergooner Lancaster, PAMember Posts: 135

    Thank you very much ... I was able to use this and get the desired results. Really appreciate it (and the spread attribute so I can adjust the curve).

Sign In or Register to comment.