How do I create a swing in the ball

0 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hey,

    I am planning to start a football penalty kick game, but not sure how does the swing in the kick works.

    When we swipe up - the ball goes towards the goal post

    and in the halfway of the swipe if I move my finger towards left - the ball should swing left.

    Even if you could show me how it works in capx (just a simple idea) that will help a lot. THANKS

  • Hi,

    see this topic:

    scirra.com/forum/behavior-swing_t64261?&hilit=swing

    maybe you understand how is working.. : -)

    Cheers..

  • odiusfly Thanks for the reply. But I am not sure how this works.

    Swing in the sense like If you check the below image, like this. If anybody could help me with a example capx, truly thanks.

  • animator :

    Your question is a bit complex, because the solution depends on how you solve the ball.

    Physical concept:

    To make a ball drift in a curve, you need to hit it off-center (can be also angled). It gets a spin through that. The spin causes the sideways-offset, since the air flowing around the ball has different speeds (thus density) on each side, so like a plane takes off, the ball goes sideways, because of air pressure differences. The bigger the rotation, the stronger the curve. (If there is no wind and you hit the ball in the middle it will not spin much, and you shoot quite straight.)

    So you could detect an offset of the hit from the center-point of the ball - the more offset, the more you let the ball fly sideways (You can also give it a rotation speed according to that, if you want realism.).

    The only question is, how you let the ball fly? A behavior?

  • Use qarp to make the ball move in curve, but you must specify the points first. You also need to measure relative distance to the target, I suggest using iterative value from variable that simulate relative 3d distance on spacial 2D.

  • MultipleChoice The ball has to fly based on the swipe speed - may be physics behavior (I am really not sure yet)

    alextro seems like freaking hard to do uh?

  • u can also use try arc, and radius or try with number variable, recording the highest pick of the X of the mouse or touch and lowest X of mouse or touch

    EX: LowXt (number) give property to save the X of touch only when X of touch is lower then initial X touch [first click on ball ]

    MaxXt (number) give property to save the x of touch only when x of touch is higher then initial Xtouch (you need a number variable for initial touch or mouse click when u click and drag the mouse call it Initialtouch lets say)

    this way u create a 3 way point, then u just use force push towards MaxXt once X of ball is = or > then maxxt force push towards lowXt and try add a delay of movement and an always rotate angle to the next way point " that way the ball will rotate toward the position u swiped i think will work logically will , hope makes sense to u if its sloppy its because im sleepy and im coding for like 48 hrs straight listening to frekain boring adventure 8 bit music on loop for some reason .... cheers and good luck

  • gamecorptm lol, thanks for the idea though. I will try these ideas now, but not sure coz it seems complicated.

    Anyway let me try first

  • Ahh, I was running through the forums searching for examples for this. How to throw a ball forward -

    I have found this post and a sample capx. - This is a example for paper toss where the paper flies up and falls down. But in football free kick ball moves forward quickly towards the net with swing.

    scirra.com/forum/viewtopic.php?f=147&t=106610&p=789849&hilit=paper+toss#p789849 - Just go to Page 2

    As C2 is not in 3D, the game has to be coded in the way that after paper flying to a certain level, there is a sprite(when the paper overlaps this sprite), reduce the paper size a bit to show it is moving forward.

    Is there any other way to do this? Applying physics behavior to the ball is fine but how to create the swing?

    -------------

    Edited:

    C2 experts kindly help me with a sample file for throwing a ball forward. It would be nice if scirra has a example for this. I am damn sure it will not only help me

  • yea there is that plugin from rainbow ... he has the swing done long time ago managed to find a link there

    scirra.com/forum/behavior-swing_t64261?&hilit=swing

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • or try this

  • Thanks Lordshiva1948, But this is not what I want.

    I am now trying the Swing Plugin. Lets see

  • yes Rex plugin best for that

  • Hey

    I have just created the set, this plugin - IDK how to swing it in the movement.

    Can somebody help me to make this ball move towards the net and swing too...

  • Bumb!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)