How to catch on collision with a part of object

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

  • 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.

  • 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.

    Hi attapi0,

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

    Thanks.

  • 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 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.

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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 :)

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