can i make a ball curve?

guillefaceguilleface Member Posts: 1,014
hello, i have a baseball that accelerates down at direction=0 related to scene, but i want the ball to curve when y position is less than 200, so i add another rule, when y position=200 to accelerate at direction=315 related to scene, it does works but is not a real curve, is looks like it just change direction diagonally to 315.

Comments

  • grimtoothgrimtooth Member Posts: 69
    direction=0 related to scene is Right, not down?

    if you are throwing a ball down, and want it to curve only when near the plate, then ill bet @SOCKS would say "The answer is most probably: AAA*sin(self.Time*BBB)+CCC"

    IF y<= 200 do:
    Constrain Self.X to (Initial X position) + 50*(sin(Self.Time*400))

    that will make the ball curve out 50 pixels from its initial position and come back in about 1 second. I assume you wont need to worry about the fact that it will want to continue oscillating because a catcher will catch the ball before that would happen.

    There is a small problem though since you are not starting the sine wave at self.time=0 you cannot guarantee that the ball will go right or left (or that it will start in the middle hehe). The fastest way to solve that would be to spawn an offscreen/invisible actor I'll call Curve.Timer, constrain its self.time to a global variable, and use that instead of "Self.Time" (Then have Curve.Timer self destruct after a few seconds to reset the timer)

    So, Right Curve-ball =
    IF y<= 200 do:
    Spawn Actor: Curve.Timer
    Constrain Self.X to (Initial X position) + 50*(sin(Curve.Timer*400))

    Left Curve-ball =
    IF y<= 200 do:
    Spawn Actor: Curve.Timer
    Constrain Self.X to (Initial X position) - 50*(sin(Curve.Timer*400))

    I would think that should work pretty well and also has the advantage of not breaking if you change the speed of the pitches :)

    Grim
  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2013
    @SOCKS would say "The answer is most probably: AAA*sin(self.Time*BBB)+CCC"
    :-\"
  • guillefaceguilleface Member Posts: 1,014
    thanks i just read your message, i will see what i can do with your formula i hope i can make it work or i just stay with my straight ball lol, i am making a pinball baseball game and i am recycling just one ball, so right now the ball accelerates from top to bottom and i hit the ball with a baseball bat, i just wanted to see if by adding a curve ball i can make the ball to travel more in different angles after touching the baseball bat.thanks
Sign In or Register to comment.