Is there a way to force bullet behaviour to move based on turns?

0 favourites
  • 14 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • Basically I have a turn based game (imagine a roguelike) and I want that projectiles in the game move in turns as well. So each turn the projectile moves a bit in a certain direction to allow the player the chance to dodge the projectile if it can (same with enemies).

    Any ideas how to achieve this with the bullet behaviour?

  • You can set bullet speed to 0, or object time scale to 0.

    But if you want your bullet to move from tile to tile, I would suggest using MoveTo behavior instead, or TileMovement behavior. You'll have precise control over it, which is not possible with Bullet.

  • You can set bullet speed to 0, or object time scale to 0.

    Setting the bullet's speed to 0 didn't work. Disabling the behaviour didn't work either. Here are my events:

    https://i.imgur.com/JqVIjha.png

    But if you want your bullet to move from tile to tile, I would suggest using MoveTo behavior instead, or TileMovement behavior. You'll have precise control over it, which is not possible with Bullet.

    No, I want the bullet to move a bit each turn. I actually would prefer if the movement doesn't follow grids, unless it is easier to do so.

  • Setting bullet speed to 0 should definitely stop it. I see your behavior is named "Bullet2", maybe you have two bullet behaviors on this object? Or there may be some other issue with your events.

  • Setting bullet speed to 0 should definitely stop it. I see your behavior is named "Bullet2", maybe you have two bullet behaviors on this object? Or there may be some other issue with your events.

    This is due to the bullet having a behaviour and then I added it to the family. So it got renamed. I removed the first one. So it has only the Bullet2.

    Any hints what could be the issue. I just create the bullet and that is it. I don't give it any other commands except setting speed to 0 as you saw.

  • If the bullet continues to fly and you don't have any other events which can change its speed, then probably the event where you set speed to 0 never triggers. You can check this by debugging.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If the bullet continues to fly and you don't have any other events which can change its speed, then probably the event where you set speed to 0 never triggers. You can check this by debugging.

    I couldn't setup a breakpoint on the events or even conditions as they are classed as a sub event or so and Breakpoints don't work on them. I tried even putting the breakpoint on the function itself and it didn't work.

    Anyway after a while of trying a few different things and experimenting I found something but not sure what to make of it. The action does work and runs. However it runs way too late.

    Once the enemy fires the projectile, the turn switches to the player and this should automatically stop the projectiles but they don't stop immediately, instead it takes them a few seconds then they stop. If I am moving the player constantly (i.e. not waiting and moving the second the turn gets to the player), this can be missed and the projectile doesn't stop.

    Any idea whys is this happening?

  • since the player has time to think about their moves, and the enemy does as well, you will probably have to set a limit to how far the bullets can move on each turn. Otherwise the player could just shoot, and then wait before completing their turn - not giving the other player/enemy a chance to move out of the way.

    I took a quick crack at it to see how I might approach it...

    a turn give each side a chance to do 3 "moves" - which could be moving the player or shooting.

    (use arrow keys to move, space bar to shoot). The enemy doesn't choose its own moves, so you have to play as both players.

    http://www.rieperts.com/games/forum/TurnShoot.c3p

  • I couldn't setup a breakpoint

    There are other ways to debug. For example, you can add "Browser log" action at the start of the function, and into the "For each projectile" event. Open the browser log in preview (F12) and you'll be able to see when these events are triggered.

    Once the enemy fires the projectile, the turn switches to the player and this should automatically stop the projectiles but they don't stop immediately,

    It's hard to guess without the project file. One possible reason is that the bullet is created and the turn is switched in the same tick. Instances that have just been created may not be accessible in other events. You need to add a small wait (at least "Wait 0") before switching the turn.

  • since the player has time to think about their moves, and the enemy does as well, you will probably have to set a limit to how far the bullets can move on each turn. Otherwise the player could just shoot, and then wait before completing their turn - not giving the other player/enemy a chance to move out of the way.

    I took a quick crack at it to see how I might approach it...

    a turn give each side a chance to do 3 "moves" - which could be moving the player or shooting.

    (use arrow keys to move, space bar to shoot). The enemy doesn't choose its own moves, so you have to play as both players.

    http://www.rieperts.com/games/forum/TurnShoot.c3p

    Thank you VERY much, that actually worked. I used your technique and it worked liked a charm. Only difference is, for some reason my bullets forget their angle of motion for some odd reason and start moving horizontally only after the turn is given back to them. I resolved it by recording the angle of motion and setting is back every turn.

    One possible reason is that the bullet is created and the turn is switched in the same tick. Instances that have just been created may not be accessible in other events. You need to add a small wait (at least "Wait 0") before switching the turn.

    That is exactly what was happening I think. The same frame the bullet was created, was the same frame the turn changed. It is good to know that wait 0 seconds would delay an action by at least a frame. This will come in handy. Thank you very much!

  • if the bullets change direction, then you have a picking issue somewhere in your code. When you think you are setting a new bullet's angle, you are accidentally setting all of them.

  • if the bullets change direction, then you have a picking issue somewhere in your code. When you think you are setting a new bullet's angle, you are accidentally setting all of them.

    I set the angle only on creation and I think when you have an action:

    -- Create someObject

    -- change angle of someObject

    Then the second action should be picking the object that was just being created not all objects right? That is the only location I ever touch the angle of the bullet. Set angle of motion and never touch it again.

  • That is correct...

    I just checked my sample with debug mode, and saw that the angle gets set to 0 when the speed is set to zero.

    I thought that might be a bug, but then I read up on the Bullet behaviour in the documentation, and it says that is how it is supposed to work. So, your solution of storing the angle is the best option.

  • That is correct...

    I just checked my sample with debug mode, and saw that the angle gets set to 0 when the speed is set to zero.

    I thought that might be a bug, but then I read up on the Bullet behaviour in the documentation, and it says that is how it is supposed to work. So, your solution of storing the angle is the best option.

    Gotcha! Really weird that this is intended behaviour... but yeah, thanks for the confirmation -- at least I am not doing something wrong :D

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