How can I specify the area of target for collision?
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
-
RThurman Posts: 2,880
@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 lolOK -- changed....
The tutorials forum is for posting tutorials to the community! -
Socks London, UK.Posts: 12,822
@dellagarpo said:
there's no issue of the two actors spawning at the same time, the issue is for them to spawn same random locationIf 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 ?
Answers
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
Spawn two actors at the same time !? Impossible !!!
exactly, that's why i'm looking for a way to do this differently
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
I think that should be (hero.Y + 180)
Gotcha
I was only joking 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
Yes... you are correct. (I forgot to account for only half the actor being above the xy point.)
Follow Up Q: How can I make two actors on prototype stage collide?
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,.
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
Sorry, I'm slow 99.7% most of the time, lol
that's what i meant, constraint it to the first spawned actor, lol
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
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).
So the answer is Real then, lol... thanks
Yes, a real attribute can be any numerical value.
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.
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.
how about the Y? sorry, just really confused right now, lol
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?
10 percent from the top is 40 percent from the centre.
ok, i get it, i'll state that if it's > 40 percent then.... whatever.