How do I create a collision area around a sprite?

Get help using Construct 2

Post » Mon Jan 12, 2015 2:08 am

First of all I'm sorry for my poor English.

Image

Well, in the image above you can see, the player sprite (green), the Enemy I sprite (yellow) and the Enemy II sprite (red). Both have a smaller and a larger circle, the smaller one is the character (player/enemy), and the largest circle is the character collision area. What do I need? I need that when any character come into any other character collision area, they attack themselves.

I do not know if that changes anything, but there may be more than 1000 characters ...

And I have no idea how to do this ...
I hope you understand my problem, thank you.
B
3
Posts: 6
Reputation: 187

Post » Mon Jan 12, 2015 4:59 am

Seeing that if u have more than 1000 chars ur .capx file would probz contain alot. But Have it check If the middle Player is Overlapping the collision Sprite, and then attack if its overlapping. Are u using a Pin function For the Middle Sprite on the Collision?
B
8
S
2
G
1
Posts: 96
Reputation: 782

Post » Mon Jan 12, 2015 6:02 am

There are two ways you can use. First, is to use a container to add a different sprite to your character sprite and have it act as the collision detection. The second, and more simpler, is to create a larger collision area for your characters. While setting up your collision points in the editor, you can actually set it outside your sprite height and width. So create a circle shaped collision and place it outside so that it is big enough to fill the area you need.
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Mon Jan 12, 2015 6:10 am

You can create an invisible sprite called collision check and set it's position to the character every thick, and use this sprite in your events to create the logic. Also, you can use line of sight behavior. If character B > has line of sight to > any character A > attack. You can use families to separate them by types of characters, like enemies, friendly character, etc.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Mon Jan 12, 2015 10:21 am

Compare Distance (Player.X, Player.Y, Enemies.X, Enemies.Y) < xPixel = Destroy?
(put Enemies into a Family)

Line of Sight would also work (better?!)
B
22
S
6
G
2
Posts: 185
Reputation: 3,632

Post » Mon Jan 12, 2015 10:32 am

kossglobal wrote:You can create an invisible sprite called collision check and set it's position to the character every thick, and use this sprite in your events to create the logic.


My question is: If i have more than 1000 sprites, how can i assign the collision check to each sprite? I don't know how to make the collision check and the sprite work as if they were one. If I had only one character would be easy to do, but if I have 1000 for example?

The player and the AI will can create an arm, things can't be static...
B
3
Posts: 6
Reputation: 187

Post » Mon Jan 12, 2015 10:38 am

rekjl wrote:..., is to use a container to add a different sprite to your character sprite and have it act as the collision detection.


Nice, I had not thought of in the containers, I will do some tests to see how they work..
B
3
Posts: 6
Reputation: 187

Post » Mon Jan 12, 2015 2:11 pm

caiokawasaki wrote:
kossglobal wrote:You can create an invisible sprite called collision check and set it's position to the character every thick, and use this sprite in your events to create the logic.


My question is: If i have more than 1000 sprites, how can i assign the collision check to each sprite? I don't know how to make the collision check and the sprite work as if they were one. If I had only one character would be easy to do, but if I have 1000 for example?

The player and the AI will can create an arm, things can't be static...


Just use line of sight behavior for the collision checks. With only this, you can create hundreds of instances of the same object and still the collision checks and actions will dealt according to each instance that have matched your condition.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests