Problem with collisions and bullet behavior

Discussion and feedback on Construct 2

Post » Fri Apr 18, 2014 1:37 pm

megatronx wrote:OK, here's mine.

Code: Select all
Bullet is on screen
For each bullet
distance(bullet.X,bullet.Y,tile.X,tIle.Y) < 10 - destroy bullet.


Of course you can replace 10 with any other number that works best for your set up.

Now I'm not sure if Bullet is on screen & For each bullet are necessary. You will have to test how it works without one or both of them. I'm using For Each often, because otherwise event applies to all instances of same type ( I'm bit confused about this since @Ashley wrote somewhere that it is working like a loop even without a loop, but from my tests it doesn't work that way, and I tend to use for each )

Another option to do is to make condition "Bullet overlapping at offset". if you set X to "-10 & 10" , and Y to "-10 & 10" too, should work ( if not try "-10 | 10"). Let me look at one of my prototypes to remind myself.

[email protected] Right, forgot that that project files got corrupted due to crash. Oh well.


Look like a nice improved addition to the problem. I will try to implement this in my example. Thanks!

Edit: Can't use your algorithm. The reason is we do not have access to the tile data. I am using a tilemap.. there no way to know which tile we going to collide.
B
16
S
5
G
1
Posts: 190
Reputation: 2,489

Post » Fri Apr 18, 2014 1:52 pm

Rushino wrote:
megatronx wrote:OK, here's mine.

Code: Select all
Bullet is on screen
For each bullet
distance(bullet.X,bullet.Y,tile.X,tIle.Y) < 10 - destroy bullet.


Of course you can replace 10 with any other number that works best for your set up.

Now I'm not sure if Bullet is on screen & For each bullet are necessary. You will have to test how it works without one or both of them. I'm using For Each often, because otherwise event applies to all instances of same type ( I'm bit confused about this since @Ashley wrote somewhere that it is working like a loop even without a loop, but from my tests it doesn't work that way, and I tend to use for each )

Another option to do is to make condition "Bullet overlapping at offset". if you set X to "-10 & 10" , and Y to "-10 & 10" too, should work ( if not try "-10 | 10"). Let me look at one of my prototypes to remind myself.

[email protected] Right, forgot that that project files got corrupted due to crash. Oh well.


Look like a nice improved addition to the problem. I will try to implement this in my example. Thanks!

Edit: Can't use your algorithm. The reason is we do not have access to the tile data. I am using a tilemap.. there no way to know which tile we going to collide.


I see. Didn't know that. But can you check if tile is solid or not?

[email protected] You could try using "Compare Tile At" after "Bullet on scree" to check for the tiles you want it to collide with. It might work!

[email protected] Also, maybe you could use 2 tilemaps, where one would be for terrain with collisions, other one for the rest!
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Fri Apr 18, 2014 3:10 pm

Here a complete example with fix on some caveat i found while doing it. Look here! After all the performance should not be a problem if you expect to have less than 50 bullets on screen. I will use this in the game since this won't happen.

viewtopic.php?f=146&t=101916
B
16
S
5
G
1
Posts: 190
Reputation: 2,489

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: tarek2 and 6 guests