How do I calculate drag/bend on a soccer ball

Get help using Construct 2

Post » Sat Jun 28, 2014 12:13 am

First of all, I don't know if "drag" is the correct term in this case, my english is not that good.

I'm trying to make a 2d top-down "Free kick" soccer game (see New Star Soccer). Where depending where you hit/kick the ball will determine the angle and force applied to the ball, including drag or effect on it, it's time on the air, etc.

You can (more or less) see what I'm talking about in this video https://www.youtube.com/watch?v=3c3kjWrF1OU

I've tried using different approaches but none of them feels right. I'm about to test using freel fall equations on y axis to calculate the flight time of the ball given certain force and angle, but the problem is the effect on the ball, I've been thinking about using the same free fall equations but with a different gravity (much smaller than 9.8). Haven't tested this.

I've tried using sin behavior to a certain value, so it goes up and continues to go down until the ball stops, but it just doesn't feel right. I think theres the qarp interpolation to simulate something like this, but don't really know how to use it, because in the examples I've seen (all by R0j0) he's using another set of x,y positions.

I could keep writing about all the ways I can think of making it work, but maybe I'm just too focused on the problem right now that I can't just see a clearer path to tackle this.

Anyways, hope you cguys can help.
Last edited by donelwero on Sat Jun 28, 2014 4:00 am, edited 1 time in total.
B
21
S
5
G
3
Posts: 53
Reputation: 3,335

Post » Sat Jun 28, 2014 12:45 am

I believe it's using "leap" which is designed by @r0j0hound

viewtopic.php?f=147&t=93771&p=729530&hilit=leaper#p729530

You have to create your own design according to angle direction and force according to width of arrow, to target position you can multiply from width of arrow, when it's ready to simulate, call leap function, you can modify this function while comparing "t" as instance variable to make it bounce and force would be divided by 2, to stop bouncing 2 times, use boolean to set isBounced.

I hope it helps you
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,371

Post » Sat Jun 28, 2014 12:52 am

Ok, I'm going to take a look at it and let you know how it went, thanks @Joannesalfa

Edit: After looking at the example and reading your post a few times I finally understood. I was able to simulate more or less the same thing, what I'm having trouble to do is the effect on the ball.

Let's say the player is shooting up (north), I still need to simulate the effect of the ball on the x axis if the player made it's shoot with effect to avoid the wall of defense in front of the player covering the goal, so the player can't shoot directly to goal.

I need to bend the the direction of the ball so it curves in mid-flight.
B
21
S
5
G
3
Posts: 53
Reputation: 3,335

Post » Sat Jun 28, 2014 6:59 am

I've amended R0j0hound's wonderful qarp example here from the following thread: https://www.scirra.com/forum/how-do-i-make-parabolic-projectile-and-movement_t103232.

Is this something like what you're after?

You can drag and drop the red 'X' then aim the ball anywhere and it will curve towards the 'X'.

Attached requires C2 r173 or greater.
You do not have the required permissions to view the files attached to this post.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Sat Jun 28, 2014 8:37 am

@zenox98 thanks, It's 3:30 am here, so I can't relly make tests with your capx but, I wll take a better look at it tomorrow. I'm thinking about moving the "target" depending on the strength and angle of the shot. I tried using qarp but I'm no math magician as R0j0hound but your capx gave me some ideas, I'll make some test in the morning and let you know how those went.

Thanks!
B
21
S
5
G
3
Posts: 53
Reputation: 3,335


Return to How do I....?

Who is online

Users browsing this forum: unicornspitfire and 64 guests