Is it possible to detect a collision based on image point?

Get help using Construct 2

Post » Mon Jun 30, 2014 11:39 pm

Hey Construct Community,

I'm trying to create a sword fighting system. Is there a way to detect when an enemy collides with the sword of the player sprite (Image Point 1) and not the whole player sprite?
B
22
S
4
G
1
Posts: 153
Reputation: 1,938

Post » Mon Jun 30, 2014 11:49 pm

You can adjust the collision mesh of the image by clicking the button below the image point button.
It's called "Set collision polygon".
B
6
S
1
Posts: 73
Reputation: 571

Post » Tue Jul 01, 2014 3:19 am

That doesn't work though because then the player's collision is tied to the sword (i.e he gets hit from behind but nothing happens because the collision is on the sword).
B
22
S
4
G
1
Posts: 153
Reputation: 1,938

Post » Tue Jul 01, 2014 7:59 am

I´m trying to do the the same thing in my project, and right now I´m using three different collision boxes.

Box one is the one I pin (using PIN-behavior) the character sprite to. This box handles the player movement.

Box two, somewhat smaller than box one, is pinned (using PIN-behavior) to box one. I use this box to check if the player gets hit. (I made it a little smaller so the player doesn´t feel he gets hit unfairly)

Box three is a rectangular box that I put on an image point I have on the sword´s edge. I don´t use PIN-behavior here (since you can´t PIN things to specific image points), but rather use: Every tick->set position to another object.
I use box three to check if the sword hits the enemies.

So far it seems to work ok, but I´ve just recently started this project, so we´ll see. :-)
I´m sure there are a lot of (probably better) ways to do this though.
B
27
S
7
G
4
Posts: 20
Reputation: 3,794

Post » Tue Jul 01, 2014 9:13 am

You can do this using just using imagepoints. Here is an example.

overlappingswordimagepoint.capx


Enemies will only be destroyed if the overlap the imagepoint "swordpoint".
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Tue Jul 01, 2014 10:51 pm

@Minor

Thanks for the example, it works perfectly!
B
22
S
4
G
1
Posts: 153
Reputation: 1,938

Post » Fri Jul 04, 2014 4:02 pm

This forum really saved me thanks alot. :D
B
7
S
1
Posts: 2
Reputation: 3,251

Post » Sun Sep 04, 2016 9:54 am

Thanks , this post and Capx is very helpful, it saved me too . :-)
B
2
Posts: 1
Reputation: 152


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, namaewayukidesu and 6 guests