How do I make an event every n pixels? (from bullet)

0 favourites
  • 8 posts
From the Asset Store
Vintage steam pixels for your UI! 125 unique assets in a single pack!
  • Hello,

    I would like to make an event that every n pixel a bullet behavior run through. (see capx)

    I have global Variable, GridSize, and I would like to make CollisionDetector's position and direction set to Player's direction + GridSize.

    In my caps, I need to keep key down to move CollisionDetector, but still not good because no n pixel ticks.

    I hope I could explain clearly what I want to do.

    Thank you so much for your help

    Capx file

  • You can 'Pin' the collision detector to the player, will that do what you want? Or is this something to do with the movement of the player, you want it to move in grid style?

  • not sure if I understood correctly but i think that the bullet behaviuor property distancetravelled should help you

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Moving on a (your) grid + move restrictions.

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

  • I made an update, changed everything but movement is super weird. I don't know how to explain so better to check the capx.

    Capx

  • Moving on a (your) grid + move restrictions.

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

    Thanks ! Working very well ! Just a question, changing the speed would be set... where ?

  • On two places.

    1/ the time when starting the timer

    2/ in the lerp (event 18) ----> lerp(Player.startX,Player.destX,Player.Timer.CurrentTime("go") * 5)

    The lerp factor (that Player.Timer.CurrentTime("go")) must count from zero to 1.

    Whit the timer counting to 0.2 (in my example) you must multiply the counter with 5. Thats is why 5 is there.

    If you start the timer with a time 0.5 it has to be Player.Timer.CurrentTime("go") * 2

    If you start the timer with a time 2.0 it has to be Player.Timer.CurrentTime("go") / 2

    So in general it is 1 / the timer time.

    How less time you give it, how faster it runs. This is already FPS in-depended. NO dt needed.

    You see ?

    Another thing. This 'set position' in event 20 is very very important. Else (because positions are like 3.333333) the little math errors will stack up, and you will run in the walls. That is also why it is difficult to make a bullet work. A bullet depends on sin and cos, hence numbers like 1.4584984949494949, and the grid is an exact multiply of 32.

  • Thank you for your time, I really appreciate your explanation

    Everything is perfect!

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