Predictive trajectory line

0 favourites
  • 4 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi everyone,

    This is my first post on the forum . Just bought Construct 2 a couple of weeks ago and have been working on a ball tossing physics game. I've spent quite a bit of time on here and have found answers to most questions from previous threads but can't for the life of me find a good way to solve the following problem:

    In my game, you can shot various sized objects with a slingshot similarly to angry birds, these balls then bounce off blocks etc. I've used a physics impulse to add the initial force to the ball. What I want to do, is to create a predictive dotted line showing exactly where the ball will end up when the player releases the mouse/touch.

    My best attempt so far has been to shoot out an invisible ball (with identical properties to the actual ball) which spawns a small black dot every 0.2 seconds until the balls is too far from the slingshot. These dots are then destroyed and a new invisible ball created every time the player moves the mouse/touch. The problem with this however is that the player will have to wait for the invisible ball to make its way across the screen every time they move their mouse. If possible, what I'd rather have is a predicted trajectory path which updates instantaneously at all times so that the player can fine-tune their shot before releasing the ball.

    Thanks in advance if anyone is able to help me out with this! I've really enjoyed my time with Construct 2 so far and must say there's an impressive amount of people on these forums who are willing to sacrifice their time to help out the community. Good on you!

  • Here's an instantaneous way to plot the path:

    It doesn't take into account collisions though. For that your current method is the only solution atm.

  • ...the player will have to wait for the invisible ball to make its way across the screen every time they move their mouse...

    Can't you just destroy the invisible ball when the mouse moves?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound - Thanks so much for the reply. I'll check it out tonight. Even if I can't get physics collisions in there it'll still be better than what I've got now.

    Citron2010 - Sorry my explanation probably wasn't good enough. The invisible ball is destroyed every time the player moves the mouse and a new invisible ball is created. The problem is that the player can't instantaneously see where the new invisible ball is going but rather will have to wait for the new invisible ball to travel across the screen before knowing where their ball will end up. Hopefully R0J0hound's trick will fix this though!

    Cheers guys

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