How do I match velocity

0 favourites
  • 14 posts
From the Asset Store
Match 3 Game Gems
$6 USD
40% off
Match 3 Game Gem Pixel Art work for any kind of Match Games.
  • Ok i thought this would be simple but its clearly way beyond me.

    All i want to do is make it so that when a bullet is fired (hitting space bar) while the player is moving (wsad) the bullet has the same directional velocity as the player.

    In the example picture you can press w to move forward and then rotate and fire. In the picture below the red arrow is your direction of travel, you rotate and fire and the green line is the path the bullet takes. I want the bullet to be fired along the green line.

    https://www.dropbox.com/s/61b6r2rqdvol3 ... .capx?dl=0

  • If I understand you correctly and you simply want the bullet to inherit the angle of motion and the speed, you can use the Custom Movement expressions of the Player.

    Like so:

    Will look like this:

  • Not quite what I meant, when you shoot your bullets It lags "behind" the player. I want it so that while you are moving towards the right but turned and shooting upward (like you do when you start shooting) for the bullet to shoot on a straight line out of the nose of the ship...

    The bullet would have to gain whatever velocity the player is moving in as well as its own.

  • If you look at the picture in game in my first post.. your bullets are also following the green line while moving to the right, i'd like them to follow the blue line

  • That is absolutely weird.

    https://www.dropbox.com/s/1pk3jnj629uwt ... .capx?dl=0

    Shoots right... along the blue line... but now after the bullet is shot it follows player rotation.

    I thought this would be simple hah

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah well, there is no 'red line' in your example. Ship moves only forward. Never according that red line.

    The velocity is always in the direction of ships angle.

    So, how do you want that bullet to move ?

  • Again from that first pic, the red arrow is the direction the ship is moving. The ship has rotated to face upwards (but is still travelling to the right, along the red line). When the bullet fires it comes out of the ship and travels along the green line because it does not gain the same directional momentum as the ship.

    Its like firing a gun on a platformer while falling - Normally The bullet would just go across the screen. I would like the bullet to "fall" with the platformer while still proceeding to travel across the screen.

  • So if the ship is moving towards the right side of the screen but turns and fires towards the top of the screen (firing towards the top of the screen while still travelling to the right) the bullet should move to the right with the ship... thus firing directly ahead along the blue line

  • skrotar

    How about this?:

    https://www.dropbox.com/s/mxz4j28nuy36d ... .capx?dl=0

    Left/Right keys to rotate, Up to accelerate and Space to fire. Word of warning: there's no clamp on the ship's max speed yet, so easy on the gas <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

  • That's it! your a life saver! thanks!!!!!!!!

  • You're welcome I'm working on the speed clamp at the mo', I'll update you when its done.

  • skrotar updated:

    https://www.dropbox.com/s/mxz4j28nuy36d ... .capx?dl=0

    I added a little bit of deceleration to get the max speed working, so a slighty hacky solution, but barely noticeable when playing - you can probably increase the ship.decel variable (= less damping) even more and it'll still work.

    If I manage to work out a proper solution (which I think involves limiting the vX, vY separately based on max speed) I'll let you know.

  • Thanks man! that looks great

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