Parabola/Tracjectory tracing with Physics / Box2D

Get help using Construct 2

Post » Sun Jan 13, 2013 3:56 pm

So am making a tank game - the general gist is mostly working, the issues that remain are accurately predicting the arc of the shell, and getting the shell turning in the air as it goes through the arc.

I had a search of the forums and turned up a few interesting things for top-down shadows on arrows and such, or solutions using canvas plugin to render an arc, but was hoping to avoid 3rd party plugins.

Here's a basic idea of how it'd look.



Test Game here -

www.johnnysix.net/games/Recoil

[ Artwork is just placeholder for now, I'll do something better once the mechanics are ironed out! ]JohnnySix2013-01-14 16:44:48
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Mon Jan 14, 2013 3:07 pm

@Ashley - for those of us that fail at maths - any chance of a feature like the following in construct? :)




Click the image to go to the page - it's about box2D.

I can't find any current examples in Construct2, not for lack of searching the manual, tutorials , forums and google.
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Mon Jan 14, 2013 4:01 pm

Ey JohnnySix
Some weeks ago I was wondering about something like that.
I searched the web and after some time analyzing different mathematic formulas and lots of martian things (to me) like those, I change my view of the problem and get a solution. I cant give it directly to you, but I can tell you (cuz mine is a very concrete example and is not adaptable for other projects) the way of getting it (very basic but it works).

The base is use the "three rule" ("regla de tres" in spanish, I dont know how to translate this :S).
Knowing the factors you may know (power, speed, or whatever) make test depending on your game resolutions, and once the bullets hits a static point, use the "three rule" to get a custom formula that works in your concrete game resolution (sorry for my bad english).

The idea is that: is the bullets hits a certain static (at first) target with your desired factors, extend it to make it works.

You cant see what I got some weeks ago (taken directly from the devlog):
sirLobito2013-01-14 16:02:28
B
14
S
4
G
3
Posts: 106
Reputation: 4,792

Post » Mon Jan 14, 2013 4:21 pm

Haha, thanks - will check it out.

I started on the Wiki page, and then lost it when I got to the formulas at the bottom.

http://en.wikipedia.org/wiki/Trajectories

I need a derivative as I'm working backwards from the mouse x/y to then calculate the appropriate velocity and angle of launch to arrive at that spot.

A Parabola would work if I turned off all friction, but it'd be less realistic.

http://en.wikipedia.org/wiki/Parabola

I'm thinking I'll just take the midpoint between the mouse x and the cannon for now and calculate a parabola for now, until I can get my head around the maths. Argh.
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Mon Jan 14, 2013 4:25 pm

When I was looking at it, I saw that most of the people (when designing a parabola for a game) create a false bullet.
A (future invisible) bullets that goes straight to the target, and the real bullets calculates the path to combining with its own speed, friction, ...
I cant help much more, sorry :/.
B
14
S
4
G
3
Posts: 106
Reputation: 4,792

Post » Mon Jan 14, 2013 4:47 pm

Yeah, that could work too - it's just as the game would get more complex, it'd need to have no collision with anything, and I think that's only possible by turning off collision with everything that is physics per item.

I found this - which makes things a little easier to understand.

http://www.yaldex.com/games-programming/0672323699_ch13lev1sec3.html

Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Mon Jan 14, 2013 6:09 pm

It seems fairly linear - I guess just calculating a parabola would be enough from a quick test.





Click image to try - this is just the gun from the game isolated.

Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Tue Jan 15, 2013 3:44 pm

Hi, any .capx for better understanding pls?
B
21
S
5
G
4
Posts: 24
Reputation: 4,596

Post » Tue Jan 15, 2013 4:25 pm

Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Tue Jan 15, 2013 5:46 pm

I'm a little unclear on what you are asking. Is it how to actually trace it, or how to derive the equation?

B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Next

Return to How do I....?

Who is online

Users browsing this forum: benajad, Braus, Google [Bot], R0J0hound, shinkan and 20 guests