Bullet, not enough collisions.

0 favourites
  • 3 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Currently in my game guns fire a long, beam to give the effect of a bullet flying along the screen.

    When the bullet overlaps a 'enemy' this is the event that takes place.

    |Bullet: is overlapping enemy

    |System: trigger once

    -------- |bullet: is overlapping enemy----------------------|enemy: subtract bullet.damage from health

    -------- |enemy: pick nearest to (bullet.imagepointX, |bullet visual: set width to distance(weapons.imagepointX,

    -------- | bullet.ImagepointY)-------------------------- | weapons.imagepointY,enemy.imagepointX,

    -------- |system: trigger once------------------------------- | enemy.imagepointY

    -------- |------------------------------------------------------------|bullet: destroy

    This is what the event looks like in construct 2. The part to the right at the start is a sub event of the event above.

    The setwidth makes the bullets visual sprite look as if it has hit the enemy and been stopped in its path.

    I know this is difficult to understand without it right in front of you but it shouldn't matter, this system is flawed, a shotgun type weapon which shoots more than one bullet at a time doesn't detect hits right, shots that are too close together(time wise) don't detect right, and shots can miss altogether.

    I chose this way because if I use a Sprite with a bullet behavior The speed that I want the bullet is around 6000, this too causes problems. The bullet can completely skip through the enemy because of the frame rate not allowing it to collide, I think.

    Now that you have seen my two options I would like to know if anyone can come up with a solution to my problem.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 6000 Pixels/seconds is really a BIG speed. Lets assume that the enemy is a big 50 pixels wide thing. Then the overlap rest only 0.013 seconds. That is dedectable at 100 ticks/seconds, but i would not count on that. So even in overlap, it will miss once in a while. Collissions at that speed is out of the question.

    Also, i have no idea at what rate you fire, but i can imagine that you have like 30 bullets when the enemy is 100 pixels away. So you have to detect 100 overlaps a second, kinda. A system that can all do that is awesome.

    The best chances to solve this you have with a 'is greater then' or 'is smaller then' comparisation. To give it room to decide. On top it needs to fast-pick the right bullet. And it should be in the form of kinda a trigger.

    To do this, i used the 'line of sight' behaviour. Add the right enemy as obstacle on creation of the bullet. Give it a small range and a small cone (i think that would be 20 in youre case, but you have to find that youre self)

    If you now use the condition 'Has LOS too object', the right bullet gets picked (but also the right enemy), and in a fast way. If you destroy the bullet then, you can even have a copy of this event running to have even higher dedection rates.

  • Thanks for coming up with a solution, but I have decided to stay with the long beam bullet effect as it is more visually appealing and I worked out a way to get it to work. Here is the new event.

    bullet: is overlapping enemy___________________|enemy: subtract bullet.damage from health

    System: trigger once___________________________|bullet:set width to distance(weapons.imagepointX,weapons.imagepointY,

    Enemy: pick nearest to (bullet.ImagepointX(0),_|_____enemy.imagepointX(0),enemy.imagepointY(0)

    bullet.imagepointY(0))__________________________|bulletvisual: set width to bullet.width

    Now the bullet fades away after 0.01 seconds solving a couple of problems, and the bullet visual sprite stays for a little bit like a visual path for the bullet.

    Now the only problem is when a shotgun shoots multiple bullets if some hit and some miss all the visual bullets will be set to a width as if they have hit, when they should just go straight past the enemy. I need a way to pair certain bulletvisual sprites to the bullet that they are spawned with. If the bullet is a in a container with bulletvisual it disappears in 0.01 seconds like the bullet, but I don't want that, it needs to stay for a bit after it has hit. If anyone knows how to solve this thanks in advance.

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