Stopping an actor

diegolaya_diegolaya_ Member Posts: 69
edited January 2015 in Working with GS (PC)

How can I make an actor stop when he reaches twice his width? Like it is a square, and I want him to move (Already done that) but I dont know how to make it stop just right after his position, like 1 square more... I already tried with a timer, but its too hard to make it stop right where i want it to stop, and I also tried creating an attribute... "If self position x = self position x + 40 (the width of the square) then change attribute, set linear velocity to 0" but it wont work... Can anyone tell me how to do it, or what am I doing wrong? Have a nice day!

«134

Comments

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

    One thing to consider is that the condition self.Position.X=self.Position+40 can never be true (if you solved the equation x=x+40 by subtracting x from both sides, you'd get 0=40). An actor can't be at one position and at 40 pixels to the right of itself at the same time. What you need to do is to set another attribute to the starting position:

    Change Attribute self.startingX (real) to self.Position.X
    If attribute self.Position.X = self.startingX+40 then ...

    You might find that ≥ works better than = for that rule since the actor may never actually be at exactly 40 pixels from the starting position.

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

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

    Make a 'real' attribute, let's call it A.

    . . . . . . .

    Change A to self.position X

    . . . . . . .

    Then have a rule that says:

    When self.position X is < A + self.width

    Move --->

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks I used < and it didnt work, I changed it to > and it worked, but just for 1 time, first time it stops, second time y doesnt stop. What should I do? Thank you

  • diegolaya_diegolaya_ Member Posts: 69

    @tatiang I don't understand something about attributes, creating an attribute and changing it to self position X shouldnt be the same as using selfposition x as well? (To make rules)

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

    @diegolaya_ said:
    I don't understand something about attributes, creating an attribute and changing it to self position X shouldnt be the same as using selfposition x as well? (To make rules)

    When you use a change attribute behavior, you're setting the value of that attribute to a number. So if for example self.Position.X is 200, then change attribute self.startingX to self.Position.X sets self.startingX to 200. But self.Position.X may change to something else, such as 210 or 220 or 230 or 240. If we compare self.Position.X at any of those points to self.startingX+40, we can see if it equals 240.

    Does that help explain it or did I confuse you more?

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

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

    @diegolaya_ said:
    Socks I used < and it didnt work, I changed it to > and it worked, but just for 1 time, first time it stops, second time y doesnt stop.

    What is 'Y' ? You've made no previous mention of 'Y' ?

    @diegolaya_ said:
    What should I do? Thank you

    Can you upload a screenshot of your rules ?

  • diegolaya_diegolaya_ Member Posts: 69

    @tatiang Wow you confused me a LOT more hahaha

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks Sorry... For "Y" I meant "It"... And yeah I can but theres too many it would be like 4 screenshots

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

    :(

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

  • diegolaya_diegolaya_ Member Posts: 69

    @‌Socks
    These are for the swipe movement (These two down here)
    file:///C:/Users/Diego/Pictures/RULES1%20BG.PNG
    file:///C:/Users/Diego/Pictures/RULES2%20BG.PNG

    I did the exact same thing for every swipe direction (Down, Left and Right)
    file:///C:/Users/Diego/Pictures/RULES%20SQUARE.PNG

    Then
    file:///C:/Users/Diego/Pictures/RULES%204.PNG

    And finally the advice you gave me
    file:///C:/Users/Diego/Pictures/RULES%20ADVICE.PNG

  • diegolaya_diegolaya_ Member Posts: 69

    @tatiang: Don't worry, I think I get it now, thanks!

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

    @diegolaya_ said:
    And finally the advice you gave me
    file:///C:/Users/Diego/Pictures/RULES%20ADVICE.PNG

    Unfortunately I have no access to your computer, you will need to host this image somewhere like TinyPic and provide a link.

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks
    My rules are all in this tutorial, I have the exact same rules as him
    you should see the video I think its easier for us both, it is 9 minutes long but you can jump some parts obviously..

    I have those rules + the rule you told me to create but I modified < to > because as I told you it didnt work till I changed it. Thanks

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

    @diegolaya_ said:
    you should see the video I think its easier for us both, it is 9 minutes long but you can jump some parts obviously..

    I'm far too lazy to search through a 9 minute video ! :smile: (not actually knowing what I am searching for), sure I can jump about in the timeline, but jump to where ? Just jump about randomly in case I land on something interesting / relevant ? :smile:

    @diegolaya_ said:
    I have those rules + the rule you told me to create but I modified < to > because as I told you it didnt work till I changed it.

    Can you not simply upload a screenshot of where you applied my rules ?

    The whole point of looking at someone's rules is that people might be able to spot a mistake or something that is causing the problem, so pointing to a set of rules in a video that we know are working fine is pretty much pointless.

    It's like telling someone that you are adding up 15 numbers but keep getting the wrong result, so they ask to see your calculations, but instead you direct them to a video of a calculation that we can clearly see is problem free.

    . . . or you call a garage and tell them your car isn't working, they ask to see the car, but instead of showing them the actual car that you are having an issue with, you point to a perfectly functioning car across the street and say 'it's exactly the same as that one' ! :smile:

    At which point you have to ask yourself what do you expect the mechanic to say ? "Oh, I think you need to replace the intake manifold gaskets" !!?

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

    Here, I made you a quick video, to show you that it works just fine.

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

    @diegolaya_ said:
    . . . If self position x = self position x + 40 (the width of the square) . . .

    P.S

    If this is all you are trying to do you could use Interpolate. make a 'real' attribute - 'orginalX'

    1) Change orginalX to Self.position.X

    2) Interpolate Self.position.X to orginalX+40

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks Wooww, and you were a lazy man?!! you just did a video for me! haha.. Yeah! I know it works, but I dont have the "move" behavior, I use Change Velocity, as my character moves according to swipes.. I you swipe right the character will change velocity to continuously move right, thats were you advice comes in, it works good, but it only works on the first swipe... if I swipe right it will stop PERFECTLY, but if I swipe again it wont stop as it did on the first swipe.. that was my question! :p (Thank you for the video by the way)

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

    @diegolaya_ said:
    I use Change Velocity, as my character moves according to swipes..

    You can get the swipe to trigger any kind of move you want, Move, Move To, Interpolate, Change Velocity etc etc.

    Is there any reason you need to use Change Velocity ?

    @diegolaya_ said:
    it works good, but it only works on the first swipe... if I swipe right it will stop PERFECTLY, but if I swipe again it wont stop as it did on the first swipe.. that was my question! :p

    If you are not willing to let people see the rules / upload a screenshot then there is very little anyone can do to help work out the issue.

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks here you go, this is where the rule you told me to create is http://es.tinypic.com/view.php?pic=t7jtr9&s=8#.VMATmSuG-oc

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks
    What do you think if I email you the project and you check it out by yourself?
    Maybe it would make it easier for you to help me? :'(

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

    @diegolaya_ said:
    Socks here you go, this is where the rule you told me to create is http://es.tinypic.com/view.php?pic=t7jtr9&s=8#.VMATmSuG-oc

    These are not the rules I suggested.

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks of course they are!! except for the "Set linear velocity to 0" because thats how I am supposed to stop it right?.. Would it be to much of a problem if I emailed you the project so that you see it better? Please??

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

    @diegolaya_ said:
    Socks of course they are!! except for the "Set linear velocity to 0" because thats how I am supposed to stop it right?..

    My suggestion was:

    Make a 'real' attribute ('A')


    Change A to self.position X

    When self.position X is < A + self.width

    Move --->

    You have:


    Change A to self.position X

    When self.position X is >= A + self.width (a guess, as you've not shown the expression window)

    Stop.

    @diegolaya_ said:
    Would it be to much of a problem if I emailed you the project so that you see it better? Please??

    No ! :) Sorry, I don't want to turn this thread into a career, lol :D I've asked you questions about your project which you haven't answered, I've made suggestions which you've not even acknowledged, and to me that's a warning sign of sorts that this very very very simple issue will take much longer than is necessary to sort out, so I'm going to have to leave it there, sorry I couldn't be any more help, but I hope you sort your issue out, best of luck.

  • diegolaya_diegolaya_ Member Posts: 69

    @Socks
    Ok I understand but youre the only one who helped me. I wanted to make clear that I have I swipe movement, so I have some rules that I cant change.. Youre asking me to change those rules so I wanted you to check them so that you know what was going on! I already tried doing EXACTLY what you told me... It stops working with swipes, and it is still moving just 1 time.. I guess Ill have to make another forum then.. thank you for your time...

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

    @diegolaya_ said:
    I guess Ill have to make another forum then.. thank you for your time...

    If by another forum you mean a separate thread for this same issue, please do not do that. You have plenty of information here already and someone else may decide to help you out.

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

  • diegolaya_diegolaya_ Member Posts: 69
    edited January 2015

    @tatiang I dont think it would be the same question... Its about the same thing but another question.. I would be about why it inly stops 1 or 2 times, but then it doesnt stop..

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

    I check the forums frequently but it doesn't mean that I read every post.

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

  • diegolaya_diegolaya_ Member Posts: 69
    edited January 2015

    tatiang I dont think it would be the same question... Its about the same thing but another question.. I would be about why it inly stops 1 or 2 times, but then it doesnt stop.." Should I open the new forum then? :s @tatiang

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

    No, I think you should post additional questions or information here. Otherwise, people have to hunt for what you've already said and it junks up the forums to have duplicate threads going, even if the questions are different.

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

  • diegolaya_diegolaya_ Member Posts: 69

    Exactly, since it seems I cant edit this forum anymore, people would have to go o the bottom of this topic to see my actual problem @tatiang

Sign In or Register to comment.