How to throw a grenade at Mouse.X and Mouse.Y

0 favourites
  • 4 posts
From the Asset Store
Throw daggers and hit the most fruit! Watch out for the wind, if you run out of daggers you'll lose the game!
  • Ok, sorry for asking again, but I know that this question as been asked and answered before, but every sample that are already posted on this forum are 404 on DropBox!

    I'm making a tower game where the ennemies are attacking my tower (tower is on the left, ennemies are coming from the right side).

    The player can click on the ennemy at X and Y to throw a grenade.

    I would like to simulate a throw with a parabolic/arc effect where the grenade will be thrown from the player and the final destination of the grenade will be the Mouse.X and Mouse.Y WITH a parabolic curve....

    I'm pretty sure that it's easy to do, so I really need your help!

    Thanks in advance, and sorry again if this question as been asked before.

  • With just two points all you exactly have defined is a line. You'll need three points to define a curve.

    The standard formula for a parabola is the following:

    y=a*x^2+b*x+c

    Plugging in the x,y positions for the three points into the formula will give you three equations where the only unknowns are a,b and c. Then it's just a matter of using standard algebra to solve for the unknowns.

    If that doesn't help, do you have more info about what you're trying to do?

    In general the process is called curve fitting:

    http://en.wikipedia.org/wiki/Curve_fitt ... 2013-06-24 18:46:22

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To much theory for my small brain

    Any C2 instructions for help? If anyone as a .capx exemple for something similar, that would really help.

    Meanwhile, thanks a lot for the info!

  • i dont have c2 so i cant check the work as im on linux; but it seems rojo has it down. these capx files arent 404d btw

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