How do I ball trajectory prediction

Get help using Construct 2

Post » Mon Oct 12, 2015 5:43 am

I actually had a look on Peggle more carefully. From what I can see from youtube, the prediction only shows the trajectory until the first obstacle is reached, to show that instantly it can be shown without physics. I am also bad at math. but how I could do it is to use R0J0hound example to draw that parabola. create balls along it, and hide the ones after the first one hits the obstacle. Is more complicated than this, but your cannon will have to be a tangent to that parabola. I am sure that if you ask R0J0hound , it will help you with that.
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Post » Mon Oct 12, 2015 5:49 am

Collisions would basically mean re-creating the physics behavior with events to be able to step the physics multiple times. Which isn't ideal at all. The way peggle probably did it was leverage the physics engine itself to do many simulation steps at once to instantly trace a path. C2's physics behavior only steps automatically per frame. It's not possible to step it manually.

For now you could get away with continuously launching balls to trace the path. It wouldn't be instant but it would show the path.
B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Mon Oct 12, 2015 6:03 am

Cant you just spawn basically a clone of the ball, have it do its bounces really fast, and then display path? basically do what the ball is going to do really really fast, and show a line where its been?>
B
10
S
4
G
3
Posts: 223
Reputation: 3,458

Post » Mon Oct 12, 2015 6:53 am

@cs2curious I tried that , but if you launch the ball faster, the trajectory changes, (it becomes more linear at the beginning), you also have to adjust the gravity to match the normal path.
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Post » Mon Oct 12, 2015 7:51 pm

Yeah, just making it faster changes where the ball would go and how much it bounces. It wouldn't match the path the ball would actually follow.

Here's a way to predict where the ball would go, including bounces. The drawback is it doesn't work with the physics behavior, instead I just used a js physics library so I could do many simulation steps at once. The second issue is that's all I made it do. For a complete game it would need to switch between predicting the path and actually moving.
viewtopic.php?f=147&t=162405
B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Mon Oct 12, 2015 8:20 pm

If you launch the ball, do a for statement, spawn another ball at the balls location, set X and Y velocity, destroy the original ball, and then continue on like that wouldn't it simulate the physics of the ball, and since it is a for statement be fast without changing the physics? I dunno, that is why I am asking XD hoping Rojohound can explain how it works.
B
10
S
4
G
3
Posts: 223
Reputation: 3,458

Post » Tue Oct 13, 2015 10:48 am

preview: https://dl.dropboxusercontent.com/u/139 ... index.html
capx: https://dl.dropboxusercontent.com/u/139 ... ry_v5.capx
For prediction curve I created a straight line consisting of 400 segments, then bend it using the formula for distance traveled by a falling object which is 0.5*gravityAcceleration*time^2 with some minor adjustments
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Post » Tue Oct 13, 2015 1:01 pm

absolutely awesome! thank you so much. You might have saved my little peggle clone :)
Have retro games for sale? Buy & Sell Retro Games UK
B
9
S
2
Posts: 68
Reputation: 768

Post » Tue Oct 13, 2015 1:34 pm

@MiniHulk Glad I could help. download v6 from here https://dl.dropboxusercontent.com/u/139 ... ry_v6.capx
I made some changes to increase prediction when hitting the vertical walls
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Previous

Return to How do I....?

Who is online

Users browsing this forum: zsoldiers and 6 guests