move to logic

GnarlyGnarly canadaMember Posts: 840

I want an actor to simply move up and down twice. Seems simple enough.

Use the "move to" behaviour.

Move to 100 200 relative to scene
move to 100 150 relative to scene.
move to 100 200 relative to scene
move to 100 150 relative to scene.

When I run it the actor moves up to 200 then back to 150 but it won't run the last two moves????????
There is some logic to this I am missing................

Thanks for any help.

Comments

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

    What rules are you using to trigger these move behaviours ?

    If you don't share your code the best you'll get from people is guesses.

  • GnarlyGnarly canadaMember Posts: 840

    Sorry early learning.
    To be honest not sure how to post "code" or screen shot. I only see URL link as option.
    That would be good to learn.

    I assumed once an actor is spawned the code is read from top to bottom. I have no triggers.

    Actor is spawned.
    I have just 4 move behaviours for that actor.

    I think I'm starting to see the problem. The code is read from top down.
    Soooooo
    It reads the first move to behavior and the actor starts to move.
    But immediately the second move to behaviour is read but its still moving to the first behaviour end point.

    All move to behaviours are read before its done finishing its first move?????? So it only looks like its following the first move.

    To resolve this......... When actor reaches end of first move to behaviour point then trigger second movement?

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    edited July 2014

    Yes you would do that.

    @gattoman said:

    To resolve this......... When actor reaches end of first move to behaviour point then trigger second movement?

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

    The FAQs include a section on adding screenshots: http://forums.gamesalad.com/discussion/66768/forum-faq.

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

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

    @gattoman said:
    I assumed once an actor is spawned the code is read from top to bottom.

    Yes, the code is read from top to bottom, but it's done in a fraction of a second - i.e. it doesn't wait until the first piece of code is completed before moving onto the next.

    If it worked like that it would make GameSalad very very limited.

    For example, imagine if you wanted an actor to move up the screen whilst spinning and changing it's colour to red, you would throw in a move to behaviour, a change colour behaviour (interpolate) and also a rotate behaviour . . . but if GameSalad worked like this all you would get is an actor that moves up the screen to its target location, then after stopping it starts to change its colour and once it has changed to red it then starts to spin . . . which is not what you were after . . . so you can probably see why carrying out behaviours serially would make things very limited !

    @gattoman said:
    When actor reaches end of first move to behaviour point then trigger second movement?

    Exactly !

    Rule 1: When actor is at position A - then move to position B
    Rule 2: When actor is at position B - then move to position A

    This will loop forever, so normally you'd stick a counter of some kind into the code so that you can tell it how many times you want it to loop.

    So, in the actor, make an attribute, let's call it counter, and change our rules a little . . .

    Rule 1: When actor is at position A [and counter is less than 12] - then [change counter to counter +1] and move to position B
    Rule 2: When actor is at position B - then move to position A

    This will loop 12 times

  • GnarlyGnarly canadaMember Posts: 840

    Thank-you
    I think I have a grip on it. Thanks for link for screen shot. Will look at it now.
    Learn a little everyday.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    I have a tutorial that shows one way to do a patrolling enemy, between two points. You could adapt that by adding a counter to stop it moving after a certain count.

  • GnarlyGnarly canadaMember Posts: 840

    Trying to post a screen shot. Dragging a Jpeg doesn't seem to work.

    SHARING SCREENSHOTS, VIDEOS, PROJECT FILES ➤ "How do I share screenshots, videos, or project files?"

    To post an image, drag it into the body of a message or use the attachment toolbar icon. To post a video, upload it to YouTube and then paste the YouTube video link into the message body.
    

    /Users/dwaynehinz/Desktop/Screen Shot 2014-07-10 at 9.50.59 AM.jpg

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

    @gattoman Hmm... works for me. Could be browser-dependent. You may want to upload the image to a file-sharing service such as Dropbox or TinyPic and then post the link here.

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

Sign In or Register to comment.