Phase Shift and Bullets

Twayne2Twayne2 Member Posts: 458
edited February 2020 in Working with GS (PC)

So, this is more about trying to find workarounds around not being able to access self.attributes of a spawned actor from other spawned actors pretty much, in a specific situation. So, if I wanted to have spawned bullets not collide with a spawned enemy unit only once alpha is at, say, .1 or .2, but otherwise collide with the enemy unit, what should I do?
I don't really see a way to do this. I may end up having to make them all stealth together, or something weird like that... not to mention problems like continuous stealth triggeration then from all actors every so-and-so seconds.
I actually just thought of spawning a new actor on top of the old one, yeah! It won't have the smooth, well I guess it could, interpolation to .1/.2 alpha... eh, that's not too important. I can fancy up the abrupt change too with some pixels. Actually, I think that the interpolate to the alpha, then spawn the new one with some added little flair, would be great. Instead of 2 seconds for stealth, it technically will be 2 + teency part of a second, because of the time to spawn the new actor, right? Haha, might make a good description if I have them in the game. :grin:
Any other suggestions?

Comments

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

    So, if I wanted to have spawned bullets not collide with a spawned enemy unit only once alpha is at, say, .1 or .2, but otherwise collide with the enemy unit, what should I do?

    Can't you detect the collision within the enemy actor's rules?

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

  • Twayne2Twayne2 Member Posts: 458
    edited February 2020

    Maybe I am missing something obvious? That would be just fine with me haha! :smiley:

    Or I didn't explain things well, (which I have certainly done before), so sorry if that's the case. Lemme try again with more of a layout of the picture with rules and whatnot.

    Let's call bullet actor bullet and stealth guy as actor stealth.
    There are two sides of the coin - rules for actor bullet's collision, and rules for actor stealth's collision, (some if not many of the rules are due to no accessing self-attributes like I keep taking about - instead of saying in actor bullet's rules "when bullet hits actor stealth and hurt him", and saying in actor stealth's rules "get destroyed once health is 0", we have to say "when bullet hits him, destroy", and when stealth is hit by the bullet, hurt himself, to give the desired bullet hurt him scenario.)

    So, we have for actor bullet:
    If actor collides with actor stealth,
    do: destroy (bullet does not have piercing abilities as most bullets usually don't)

    we also have a move actor saying "move right at such and such a speed".

    Now, for actor stealth, we have:

    If collides with actor bullet,
    sub-rule:
    if self.alpha is greater than ex. .1
    do:
    change self.health to self.health - x.
    else:
    nothing.
    So currently we have if bullet hits actor stealth, it gets destroyed no matter what. (This is the problem.) If actor stealth collides the bullet, (which he does just like the bullet haha), he hurts himself if he is non-stealth/going stealth.

    So how do I make the bullet not collide with all actor stealths, when there are multiple spawned instances of him? We can't say "if global attribute.stealth is 1, don't collide", because not all actor stealths will be stealthed at the same time.

  • Twayne2Twayne2 Member Posts: 458

    So I guess we can have the stealth actor not collide with the bullet, but the bullet would still hit him. He could deflect bullets! But that's not what I really want... (All enemies behind him would be shielded - no fair!) :grin:

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

    @Twayne2 -- how about making a rule in actor stealth that that says (when alpha > .1 and collides with bullet) then spawn an invisible actor "DestroyingAngel".

    Then in actor bullet make a rule that says (when bullet collides with DestroyingAngel) then destroy. (You will also need to destroy "DestroyingAngel".

    or

    You could set up the stealth actor with tags. Such as "Killable" and "notKillable" And when alpha > .1 give it the tag "Killable" else change the tag to "notKillable". (Or just remove the tag.)

    And then you can have the bullet actor check for collisions with actors of type "killable"

  • Twayne2Twayne2 Member Posts: 458

    ...
    or

    You could set up the stealth actor with tags. Such as "Killable" and "notKillable" And when alpha > .1 give it the tag "Killable" else change the tag to "notKillable". (Or just remove the tag.)

    And then you can have the bullet actor check for collisions with actors of type "killable"

    This is genius @RThurman! Your first option is what I thought of eventually earlier, and was planning on going with, but this works great! Can you tell me if its possible to change an actor back to no tag? (Really back to the "All" tag). (Oops, actors always are in it). In the self.tags options, it just shows the newly created tags. So I have to create two tags, (Destroyable and Undestroyable). Or do I?

    Also, what is game.tags? Like, what does it do? Can we change it?

  • Twayne2Twayne2 Member Posts: 458

    If I said change self.tags to None, would that make the actor not be a part of a special tag? Just thinking ahead, not actually needing this quite yet.

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

    @Twayne2 -- the self.tags attribute is of type 'text'. So you can manipulate it with all of the text (string) functions. You can add, remove, concatenate, splice, & insert text/string elements.

    You can remove all text from the attribute (which removes any tags). Or you can add any string of text to make a new tag.

    The self.tags attribute can hold many tags. Just make sure they are separated by a comma. Hmm....other separators (like /,|,\,', or " ") might work, but I just use commas.

    While you can put any tag in the attribute, when you want to test for a condition, the rules use a drop down menu of available tags. That will mean that you have to have the tags pre-defined when you want to test if an actor has the tag.

Sign In or Register to comment.