When actor is missed, change an attribute ?

Jugoslav85Jugoslav85 Member, PRO Posts: 36

I am building a game, where when a spawning actor is touched, the attribute value goes +1. Now i want to change that attribute to 0 when he miss the actor.

I tried this way:
When the background is touched (in that case, he missed the actor), change attribute game.xxxxx to 0
The problem is, that since the actor is spawned and moving all around the scene, when i touch the actor, it register it like i have touched the background too, and my attribute does not goes +1.

I believe it is something very easy, but i cannot figure it out for hours.

Best Answer

  • RThurmanRThurman Posts: 2,881
    Accepted Answer

    @Jugoslav85‌
    @tatiang‌

    Here is a file that detects if a target (evil) actor is clicked. If yes, then the score is incremented. If no, then the background actor sets the score to zero.

    Will this work?

Answers

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

    Try using When Touch is Outside instead of When Touch is Pressed.

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

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    @tatiang said:
    Try using When Touch is Outside instead of When Touch is Pressed.

    Hi Tatiang, thanks for the reply. Your suggestion makes sense, but unfortunately, it didn't work for me. Can you please explain better on which actor should i change the touch to outside instead of pressed.

    I tried many things like:
    When actor's touch is inside change attribute to +1, else; change attribute to 0 (also; rule/ if touch is outside change attribute to 0)
    when actor's touch is outside change attribute to 0
    when background touch is pressed/inside/outside change attribute to 0
    and few others options....

    Every time attribute value do not go +1, or it goes +1 and goes back to 0.

    Any other suggestion if this one doesn't work ?

    Thanks in advance

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

    This is what I mean:

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

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36
    edited May 2014

    @tatiang said:
    This is what I mean:

    Thanks for the super quick answer. I did a test on a new project, and this works perfectly when the actor is dragged on the scene. The thing is that my actors are spawned by an other actor which is outside of the scene. In these case, it does not work. I have no idea how to figure it out.

    Any clue what could fix it ?

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36
    edited May 2014

    The problem is that when i press on one actor multiple times, it counts +1, but when i press an other spawned actor of the same type, it goes to 0.

    @tatiang said:
    This is what I mean:

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    Hey guys,

    This is my second question for the same issue, the first one was marked as answered, even if it wasn't. A link from that question: http://forums.gamesalad.com/discussion/68320/when-actor-is-missed-change-an-attribute

    Now: I want to make a combo meter that increments +1 every time you click an "evil" actor. When you miss the actor, the combo resets to 0.

    I tried making an invisible actor that occupies the background, but every time you click the "evil" actor it also registers a click on the background so the combo always reads 0. Is there a way to detect a click on the "evil" but not on the background?

    I also tried the rules: When touch is pressed change attribute (combo) to +1, than When touch is outside change attribute(combo) to 0. This works only if there is one actor spawned. The moment i press on an other spawned "evil" actor, the combo counter goes to 0.

    Thanks in advance.

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

    Well, now that I know more about your scene I can tell you that my solution won't work. This is why it's important to give details about what you're trying to do. You're actually spawning multiple actors, which requires a different approach.

    If I have time, I'll post another suggestion.

    Also, no need to start a new thread... just post another question in this existing thread which I've merged with the one you just created.

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

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    @tatiang said:
    Well, now that I know more about your scene I can tell you that my solution won't work. This is why it's important to give details about what you're trying to do. You're actually spawning multiple actors, which requires a different approach.

    If I have time, I'll post another suggestion.

    Also, no need to start a new thread... just post another question in this existing thread which I've merged with the one you just created.

    That would be really great, thank you. I didn't know how to explain better, that is why i missed this very important thing :).

    I have tried pretty much everything i found on the forum and youtube, nothing really helped.

    I really appreciate your effort.

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    Anyone else who know more about this ? I couldn't find anything in the forums so far.

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

    Here's kind of an unorthodox way to do it: https://www.dropbox.com/s/19v4xrekn0j5wf4/touch to score.zip

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

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    @tatiang said:
    Here's kind of an unorthodox way to do it: https://www.dropbox.com/s/19v4xrekn0j5wf4/touch to score.zip

    Hi Tatiang,

    First of all, thank you for doing your best to help a stranger. I owe you a pack of beer :)

    Now, i have changed your file a little bit to show you what my situation is.

    https://www.dropbox.com/s/wx5xfsu3ka9lo3r/My issue.zip

    Download it and preview, it is just like in my project.

    A spawner actor located outside the scene is spawning enemies, which after being touched change attribute Combo to Combo +1, and after missed, reset Combo to 0.

    Let me know if you have a solution on that, or if you don't also let me know so i start planning a way to build my game without Combo. This is stopping my progress for days, if nothing can be done, i will have to let it go.

    Thanks one more time for your effort.

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

    Yes, I see the problem. The movement effects the touch detection. I'll think about another method and let you know what I come up with.

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

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    @tatiang said:
    Yes, I see the problem. The movement effects the touch detection. I'll think about another method and let you know what I come up with.

    Thanks again, I will wait for your reply.

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

    Much better, @RThurman. :)

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

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    @RThurman said:
    Jugoslav85‌
    tatiang‌

    Here is a file that detects if a target (evil) actor is clicked. If yes, then the score is incremented. If no, then the background actor sets the score to zero.

    Will this work?

    Works perfectly !!!

    Thanks a lot to both of you guys. I LOVE this forum !

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited May 2014

    @tatiang said:
    Much better, RThurman. :)

    Good! Sometimes it just takes a fresh set of eyes to see the issue in a slightly different way.

    @Jugoslav85 said:
    Thanks a lot to both of you guys. I LOVE this forum !

    You are welcome. I hope it works well for you. (The forum is pretty awesome, isn't it. A great product like GameSalad deserves a great forum.)

    --RT

  • Jugoslav85Jugoslav85 Member, PRO Posts: 36

    @RThurman said:
    --RT

    Exactly, this is my first project, and i have managed to do many things on my own cause GS is very easy to work with and you get great results just by trying to find the logic solution.

    Sometimes, we all need someone more experienced to figure out how some things can be done.

    Thanks again, i will post my project once i have it published.

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

    @Jugoslav85‌ -- Looking forward to seeing what you create!

  • steeveeceesteeveecee Member Posts: 1

    @RThurman said:
    Jugoslav85‌
    tatiang‌

    Here is a file that detects if a target (evil) actor is clicked. If yes, then the score is incremented. If no, then the background actor sets the score to zero.

    Will this work?

    What was the solution to this? I don't see any file :/

Sign In or Register to comment.