How to catch on collision with a part of object

Get help using Construct 2

Post » Wed Sep 04, 2013 9:43 am

Hi there,

I am working on a shooter game. On my game, I want to catch 2 different events when player shoots the enemy and when player shoots to the head of the enemy. I tried to use Bullet - On Collision with - Enemy but can not catch whether it shoots to the body of the enemy or the head of the enemy.

Is there any way for me to do it?

Thanks in advance.
B
10
S
4
G
2
Posts: 36
Reputation: 2,207

Post » Wed Sep 04, 2013 9:49 am

I may be way off here. But from what I'm guessing you should be using a container
Don't take my word for it though, I'm only like 50% sure and I don't feel like testing it right now. attapi02013-09-04 09:50:50
B
3
Posts: 5
Reputation: 210

Post » Wed Sep 04, 2013 9:54 am

[QUOTE=attapi0] I may be way off here. But from what I'm guessing you should be using a container
Don't take my word for it though, I'm only like 50% sure and I don't feel like testing it right now. [/QUOTE]

Hi attapi0,

Could you explain a little bit clearly about the container that you said.

Thanks.
B
10
S
4
G
2
Posts: 36
Reputation: 2,207

Post » Wed Sep 04, 2013 10:00 am

You could make a seperate sprite for the head and use a container.

Or maybe just make a condition
bullet -on collision with enemy
if bullet.y < enemy.y

if your enemy's origin is in the middle this would mean an upperbody hit. I'm not really sure if the picking would be correct in this case, but with a bit of fooling around you should be able to get it working.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Sep 04, 2013 12:43 pm

I am still fresh in C2, but maybe... You create a body sprite (a blue rectangle for example) and a head sprite (red and smaller rectangle). Position red rectangle on top of blue rectangle... Give pin behaviour to head, and on start of layout, pin the head to body (position and angle perhaps.) Then you can check the collision seperately for the body and head.

If you have animations for this character, you can also create them and pin them to blue rectangle too. And then make the rectangles invisible.

I am sure there are better solutions but... Maybe this helps of gives new ideas.
B
17
S
4
G
1
Posts: 332
Reputation: 3,099

Post » Thu Sep 05, 2013 12:33 am

@LittleStain and @Windwalker:

Thanks four your suggestions. Actually, both solutions work as I already tested it. Nevertheless, what I gonna do is that I set a second image point, then compare the bullet.Y with the enemy.Y as LittleStain suggested. It works as I expected.

Again, thanks you guys. :D
B
10
S
4
G
2
Posts: 36
Reputation: 2,207

Post » Thu Sep 05, 2013 6:12 pm

@detno29, as long as your enemy is not upside down, this should work :D But what works is what works, show us your game sometime :)
B
17
S
4
G
1
Posts: 332
Reputation: 3,099


Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 9 guests