GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How can I specify the area of target for collision?

Dell7730Dell7730 Posts: 388Member, PRO
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

«1

Answers

  • SocksSocks London, UK.Posts: 12,822Member
    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 Posts: 388Member, PRO

    @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.Posts: 12,822Member

    @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 Posts: 388Member, PRO

    @Socks said:
    :tongue:

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

  • RThurmanRThurman Posts: 2,823Member, Sous Chef, PRO
    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 Posts: 388Member, PRO

    @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.Posts: 12,822Member

    @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 Posts: 388Member, PRO

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

    Gotcha

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

    @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 Posts: 388Member, PRO

    @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 Posts: 2,823Member, Sous Chef, PRO

    @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 Posts: 388Member, PRO

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

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

    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 Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef

    @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 Posts: 388Member, PRO

    @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 Posts: 388Member, PRO

    @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.Posts: 12,822Member

    @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 Posts: 388Member, PRO

    @Socks said:

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

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

    @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 Posts: 388Member, PRO

    @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.Posts: 12,822Member

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

    Yes, a real attribute can be any numerical value.

  • Dell7730Dell7730 Posts: 388Member, PRO

    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.Posts: 12,822Member
    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 Posts: 388Member, PRO

    @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.Posts: 12,822Member

    @Dell Agarpo said:
    how about the Y?

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

  • Dell7730Dell7730 Posts: 388Member, PRO

    @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.Posts: 12,822Member

    @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 Posts: 388Member, PRO
    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.