How can I specify the area of target for collision?

Dell7730Dell7730 Member, PRO Posts: 388
edited April 2015 in Working with GS (PC)

In my shooting game, I would like my target actor to only die when hit in the head, so for example the height is 400 pixels and the head area is 380 to 400 pixel, how can I specify my bullet to only trigger a rule when hitting that specific area?

Best Answers

  • RThurmanRThurman Posts: 2,880
    Accepted Answer

    @dellagarpo said:
    Thanks for the recipe, as for moving it, it's up to you, lol... I always start on this section cause I feel the need to be tutored lol

    OK -- changed....
    The tutorials forum is for posting tutorials to the community!

  • SocksSocks London, UK.Posts: 12,822
    edited April 2015 Accepted Answer

    @dellagarpo said:
    there's no issue of the two actors spawning at the same time, the issue is for them to spawn same random location

    If you are spawning two actors, spawn the first one at your random location and have this first actor spawn the second actor (at 0,0 relative to actor).

    @dellagarpo said:
    and for them to reattach themselves together

    'reattach' ? Not sure what you mean by reattach, do you want the second actor to be constrained to the first actor ?

«1

Answers

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    The most straightforward way would be to constrain a smaller actor to the main actor, and use this as the target area.

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:
    The most straightforward way would be to constrain a smaller actor to the main actor, and use this as the target area.

    that was actually my original idea but the target actor is programmed to respawn another when killed, so if I constrain another actor to it, i'll have to respawn that also at the exact same time and same location with the target actor

  • SocksSocks London, UK.Member Posts: 12,822

    @dellagarpo said:
    that was actually my original idea but the target actor is programmed to respawn another when killed, so if I constrain another actor to it, i'll have to respawn that also at the exact same time and same location with the target actor

    Spawn two actors at the same time !? Impossible !!!

    :tongue:

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:
    :tongue:

    exactly, that's why i'm looking for a way to do this differently

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited April 2015

    Try something like this:

    When hero collides with bullet
    and
    bullet.Y is > (hero.Y + 380) then
    (do your thing)

    Edit: Is there a reason that this is posted in the 'community tutorials' forum? Do you want it moved to 'Working with GS(Mac) forum?

  • Dell7730Dell7730 Member, PRO Posts: 388

    @RThurman said:
    Try something like this:

    When hero collides with bullet
    and
    bullet.Y is > (hero.Y + 380) then
    (do your thing)

    Edit: Is there a reason that this is posted in the 'community tutorials' forum? Do you want it moved to 'Working with GS(Mac) forum?

    Thanks for the recipe, as for moving it, it's up to you, lol... I always start on this section cause I feel the need to be tutored lol

  • SocksSocks London, UK.Member Posts: 12,822

    @RThurman said:
    Try something like this:

    When hero collides with bullet
    and
    bullet.Y is > (hero.Y + 380) then

    I think that should be (hero.Y + 180)

  • Dell7730Dell7730 Member, PRO Posts: 388

    @RThurman said:
    The tutorials forum is for posting tutorials to the community!

    Gotcha

  • SocksSocks London, UK.Member Posts: 12,822

    @dellagarpo said:
    exactly, that's why i'm looking for a way to do this differently

    I was only joking :tongue: it is possible to spawn two actors at the same time, what was the issue when you tried ?

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:
    I was only joking :tongue: it is possible to spawn two actors at the same time, what was the issue when you tried ?

    there's no issue of the two actors spawning at the same time, the issue is for them to spawn same random location and for them to reattach themselves together

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @Socks said:
    I think that should be (hero.Y + 180)

    Yes... you are correct. (I forgot to account for only half the actor being above the xy point.)

  • Dell7730Dell7730 Member, PRO Posts: 388

    Follow Up Q: How can I make two actors on prototype stage collide?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Get one or both actors to move in such a fashion that that they eventually occupy the same space.

    You can use such actions as move, moveto, change velocity, etc,.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @dellagarpo said:
    Thanks for the recipe, as for moving it, it's up to you, lol... I always start on this section cause I feel the need to be tutored lol

    I've already asked you to post new threads in Working with GS (PC). The quality of responses you get is dependent on creating a thread in the correct subforum since the software does differ in small ways between the two platforms.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Dell7730Dell7730 Member, PRO Posts: 388

    @tatiang said:
    I've already asked you to post new threads in Working with GS (PC). The quality of responses you get is dependent on creating a thread in the correct subforum since the software does differ in small ways between the two platforms.

    Sorry, I'm slow 99.7% most of the time, lol

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:
    'reattach' ? Not sure what you mean by reattach, do you want the second actor to be constrained to the first actor ?

    that's what i meant, constraint it to the first spawned actor, lol

  • SocksSocks London, UK.Member Posts: 12,822

    @dellagarpo said:
    that's what i meant, constraint it to the first spawned actor

    Two game attributes game.X and game.Y.

    In the first actor:
    Constrain game.X to self.X
    Constrain game.Y to self.Y

    In the second actor:
    Constrain self.X to game.X + whatever offset you want
    Constrain self.Y to game.Y + whatever offset you want

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:

    the game.X,Y is that Boolean or Real? just making sure

  • SocksSocks London, UK.Member Posts: 12,822

    @dellagarpo said:
    the game.X,Y is that Boolean or Real? just making sure

    A boolean variable/attribute is binary, by that I mean it can exist in only two states, off and on, or 0 and 1, true or false . . . (etc).

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:
    A boolean variable/attribute is binary, by that I mean it can exist in only two states, off and on, or 0 and 1, true or false . . . (etc).

    So the answer is Real then, lol... thanks

  • SocksSocks London, UK.Member Posts: 12,822

    @dellagarpo said:
    So the answer is Real then, lol... thanks

    Yes, a real attribute can be any numerical value.

  • Dell7730Dell7730 Member, PRO Posts: 388

    No specific height and width, how do you code to determine 10 percent top of the image on its Y position and 12 percent from the center of its X position as illustrated by the red oblong on her head?

    I'm trying to get percentage instead of specific number cause the target varies in sizes, some are big to make it seem close and some small to make it seem far, or target starts small due to distance and gets bigger as it gets closer that's why it's in percentage and not in specific number.

    Reason for this also why I want to determine the area specifically is in any shooting game depending on who makes it, I want to have a different score points on various area of hit, for example, if I hit below the waist line, it'll be 5 points, if I hit from waistline to the eyebrows, it's 10 points, if I hit the head area, it's 25 points.

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    @Dell Agarpo said:
    No specific height and width, how do you code to determine 10 percent top of the image on its Y position and 12 percent from the center of its X position as illustrated by the red oblong on her head?

    Use the actor's height and width values to calculate % values.

    i.e. Actor's width / 8.3333 = 12%

    P.S. GameSalad doesn't support elliptical collision shapes, only rectangles and circles.

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:
    P.S. GameSalad doesn't support elliptical collision shapes, only rectangles and circles.

    how about the Y? sorry, just really confused right now, lol

  • SocksSocks London, UK.Member Posts: 12,822

    @Dell Agarpo said:
    how about the Y?

    Are you asking how to calculate 10% of a value ?

  • Dell7730Dell7730 Member, PRO Posts: 388

    @Socks said:

    @Socks said:
    Are you asking how to calculate 10% of a value ?

    No, getting the percentage value from center of the x and y position is easy, but like on the illustration, how do you get it to state 10 percent from top of the image?

  • SocksSocks London, UK.Member Posts: 12,822

    @Dell Agarpo said:
    No, getting the percentage value from center of the x and y position is easy, but like on the illustration, how do you get it to state 10 percent from top of the image?

    10 percent from the top is 40 percent from the centre.

  • Dell7730Dell7730 Member, PRO Posts: 388
    edited April 2015

    @Socks said:

    ok, i get it, i'll state that if it's > 40 percent then.... whatever.

Sign In or Register to comment.