How could I make bullets do this?

0 favourites
  • 8 posts
  • Hello Constructors,

    I've come to regret not studying harder at math in high school. I'm trying to figure out how to shoot three bullets that arc upwards at three different angles:

    • The red bullet rotates to a 90 degree angle after 1 second of forward momentum

    • The green rotates to an 80 degree angle after 2 seconds

    • And the blue to 70 degrees after 3 seconds

    If anyone has any clues on equations or construct methods, I'd really appreciate it.

    Thanks!

  • The one formula to know for motion is:

    speed*time=distance

    Take the red bullet as and example. You know the time (1 second) and the distance (90 degrees). so the equation is:

    speed*1 = 90

    You want to know the speed of the rotation so isolate speed on one side and we get:

    speed = 90/1

    or

    speed =90

    then you can do the motion with an event like:

    every tick:

    --- rotate red 90*dt degrees counter-clockwise

    --- rotate green 40*dt degrees counter-clockwise

    --- rotate blue 70/2*dt degrees counter-clockwise

    My next question is do you want the bullets to continue turning after that of just continue straight?

    If continue staight use "rotate toward angle" instead.

  • I think you misread his question a bit R0j0hound. The duration he stated are for forward momentum only. There is no talk of arcing duration nor speed, he should probably specify those as well to get a better answer.

    I'd say set a timer on each bullet and start arcing when the forward movement is done, by applying a "rotate toward angle" action every tick as R0J0 said. (with an angular speed yet to be determined)

  • Ah, true. I missed that forward momentum bit.

  • This is all fascinating and very helpful! Thanks so much to you both for taking the time, especially with helping me understand the formula. Teach a man to fish, as they say. I was indeed intending on the bullets continuing forward while bending; my fault for not being specific. Gameplay may change that, though. This is just my pencil sketch. Anyway I'll give it a crack this weekend and report back. Thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Following R0J0hound's and Magistross's instructions, I made an example capx: https://www.dropbox.com/s/vag52wm4u25qk ... .capx?dl=0

    You'll need C2 version 212.2 in order to open it.

  • You want bullets that fly straight for some time then change course?

    For the bullets, add a instance variable, call it:

    IsTurning=0

    Then use On Create(Bullet) -> wait (time that you want bullet to go straight) -> set IsTurning=1

    Bullet (Compare Instance), IsTurning=1 -> Rotate towards whichever direction.

    It's what I use for my missiles in Star Nomad 2, when you launch it, it flies straight for some time (adding ship velocity) before activating the thruster & target seeker AI.

  • Thanks to you all — mission accomplished!

    Really appreciated the capx and the math tutorial; it's helping with other angular bullet ideas.

    Looking forward to Star Nomad 2!

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