Moving actors in a circle and/or a predetermined path

2

Comments

  • Village IdiotVillage Idiot Member, PRO Posts: 486
    edited July 2017

    Thanks guys.. @Socks @Icebox @RThurman
    I've been giving this some thought and I'm leaning towards the idea of using tables as RThurman has demonstrated.

    I get the impression from what I've seen in the forums regarding getting other things done that tables are important to learn. I've been reluctant to date as they frighten me (more to the point, my feeble mind struggles with them – I shake my fist at my DNA). Icebox, your solution has me impressed but is to me even more frightening than tables (as in, more advanced looking) – though I like what's going on there – it seems like a sneaky way to do it.

    Icebox, I'm wondering why you've put 999 rows in that table? I'm thinking that the more rows you have, the smoother the movement.. is that right? If you were to have put 9999 – would the movement be smoother – or is that the limit or is 999 adequate?

    @Socks – do you really think game attributes are for losers – are you saying that they're not the best thing to use?

    PS: Do you think that Two.Es' new course on grids and tables would be a good idea? I'm thinking yes.. although it would have me divert from making my game, I think I might need it to help me get my head around the subject. I don't even know what grids are – but I'm guessing that more learning is good.

  • IceboxIcebox Member Posts: 1,485

    Icebox, I'm wondering why you've put 999 rows in that table?

    I think you mean RThurman , I didn't use any tables , i'm surprised you find my solution advanced , its quiet easy i might have confused you with timers xD sorry , anyway good luck with it , I recommend looking at any tutorial on tables and i think Two.E would be the best.

    although it would have me divert from making my game

    Things just come together at some point . If you learn tables , you might change your whole project , if you learn about one thing it might make other things easier . The more you learn the better , i'm not a pro/advanced user but i keep learning from these threads in the forums and at some point i always use the knowledge the members provide. So don't think that it will divert you from your game , it will eventually help you understand GS more hence better programming skills.

  • Village IdiotVillage Idiot Member, PRO Posts: 486

    @Icebox – oh, sorry, got the names mixed up.. I think you're right, I'll do the course – only goes for an hour, but I think anything is better than nothing – and it seems to be fairly priced ($19 Oz money).

    Re the confusion.. I'm really shite at anything remotely maths like.. I mean really. I was the kid in school that was at the back of the class scribbling on the desk – hence, why I work as a gardener (lawn mowing guy) now :)

    I'm not giving up though.. because I'm like the cookie monster for punishment..

  • Two.ETwo.E Member Posts: 599

    Tables (and grid) are often overlooked due to the complexity attached to them. They are very simple to understand. Its just getting around the expression editor and the what each table function does. Once you understand the basic, the rest sort of fall into place.

    I've been trying to make it easy to learn more about them with demos and tutorials. Its slow going at the moment but got a lot of neat things being worked on, so hopefully the pace will pick up soon.

    That said, you can check GSlearn for about 4-5 demos that use tables if you are looking for some more demos. I think there is a word one, a level based jumper, some basic table movement etc.

    Best,

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

    @monkeyboy simian -- the 999 rows in the table is purely arbitrary. It could have been 100 rows instead. You notice the modulo operator (the % sign)? That just starts the position recording over again at row 1 when the row counter reaches 999.

    Having more or less rows won't make the movement less choppy. Choppiness is because of the timer. It is also because the actor is just jumping to the next position. There is no smooth movement.

    That demo was just to show the bare minimum of what would work. It is not meant for final production. Once you have the positions recorded in a table, you can use all sorts of fancy GameSalad tricks to get smoother movement.

  • Village IdiotVillage Idiot Member, PRO Posts: 486
    edited July 2017

    @Two.E – Just finished your course.. nice job, very professional and clear. I wish there were more tutorials of this caliber. I think it's given me a greater familiarity with the subject. Though I now have to apply this to my project.

    @RThurman – Regarding the 999 – is that making a grid? With the x and y positions both having 999 x 999 places that the actor can be? Like this t shirt booth tutorial:

    Sadly I suspect the template is no longer available as he seems to be long gone and this tutorial is ancient.

    I'll have a tinker with your demo.. Thanks for the help.

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

    @monkeyboy simian said:
    @RThurman – Regarding the 999 – is that making a grid? With the x and y positions both having 999 x 999 places that the actor can be? Like this t shirt booth tutorial:

    No -- no grid there. It is just recording the x,y positions of the 'leader' actor every so often. (Each row of the table is one snapshot of its position.) Then it has the 'follower' actor jump to each of those recorded positions - row by row. When it reaches row 999, it starts over again at row 1.

  • Village IdiotVillage Idiot Member, PRO Posts: 486

    @RThurman – oh... So those x and y columns, the whole table are just there for the purpose of recording those positions – so that they can be read by the follower? I'm still unsure as to why so many then. Is it to make it more accurate – to account for any turns etc?

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

    The number of rows was completely arbitrary. It could have been 100 or 100000 depending on need.

    But you do need to have some rows, because the 'follower' actor lags behind the 'leader' actor a little. So while the 'leader' is recording its current positions in rows 100,101,102, etc., the 'follower' is jumping to the positions as recorded in rows 50,51,52, etc.

    I was to lazy to calculate the exact number of rows needed. But I felt it would probably be enough if there were 999 rows.

  • Village IdiotVillage Idiot Member, PRO Posts: 486
    edited July 2017

    Thanks @RThurman – I think I need to play with the demo a bit to grasp this.. When you say calculate the exact number.. how would you do that.. and why?

    PS: Was looking here:

    and can't work out what's going on in the expression editor.. particularly this bit: +1)%999)+1

    I don't understand the percentage signs' purpose. You mentioned something about modulo.. I'm not very familiar with it and especially with reference to GS.

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

    @monkeyboy simian said:

    and can't work out what's going on in the expression editor.. particularly this bit: +1)%999)+1

    I don't understand the percentage signs' purpose. You mentioned something about modulo.. I'm not very familiar with it and especially with reference to GS.

    The modulus operator has been explained several times on the forums. Here is one:
    http://forums.gamesalad.com/discussion/comment/596847/#Comment_596847

    Here is another:
    http://forums.gamesalad.com/discussion/comment/423924/#Comment_423924

    In the case above its just counting from 1 to 999 then starting over.

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

    @monkeyboy simian said:
    Thanks @RThurman – I think I need to play with the demo a bit to grasp this.. When you say calculate the exact number.. how would you do that.. and why?

    Why calculate the exact number of rows? I guess it may be important under certain circumstances. But I didn't think it was necessary. I already admitted that I was too lazy to do that!

    How would you calculate the exact number of rows? Well.... now that I think about it, I suppose an easy way would be to multiply the follower's time delay by 60. (Since GS operates at 60 frames per second -- at its fastest.) Therefore, a 2 second delay would need at least 120 rows. A 5 second delay would need at least 300 rows. And at 999 rows, you could delay the follower actor for up to 16.65 seconds!

  • Village IdiotVillage Idiot Member, PRO Posts: 486

    Thanks for your patience @RThurman – I know I'm quite "special needs" with this. I looked into the modulus thing and I think I've got a better understanding of that now. I'll just try and apply it... hopefully I'll improve. Thanks again, much appreciated.

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

    You are welcome!

    I am sure that with practice, using the mod function will become easier and easier. Soon (like me) you will probably use it every day for all sorts of interesting reasons. It really is a very handy 'tool' for game developers.

  • Village IdiotVillage Idiot Member, PRO Posts: 486
    edited August 2017

    I've managed to make some progress here @RThurman . Though I'm having trouble trying to achieve my objective. I've attached a rough image of what I'm going for below.

    I'm aiming for a smooth movement (which is happening) though the follower actor rushes after the leader. I was hoping to make it so they both begin in their respective positions and move around the way indicated above. The different colours represent different actors – Ideally, I'd like to have something like this in the end.

    Here's video showing what's happening (it's just at the beginning, the first few seconds that I'm talking about).

    I'm pretty sure it's something to do timers, but I've tried changing the times and it doesn't seem to help. Any ideas?

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

    Do they always follow that triangular path? Or can the leader start doing other paths?

    If they always go in a triangular path, then use some of the other methods suggested.

    If the leader does not follow a set path, then do the method I showed.

    The second actor's lag and jump at the beginning is a combination of: 1) the timer (as you surmised), and 2) the fact the the second actor is jumping to the beginning position of the first actor. (It is jumping to the position recorded in row 1 of the table.) It is doing exactly what it was set up to do!

  • Village IdiotVillage Idiot Member, PRO Posts: 486
    edited August 2017

    @RThurman – Yes, the idea was to have the leader and followers all travel along a triangular path. So I'm guessing there's no way of getting around that initial jump forward? I was hoping that there'd be some sort of timer trick that I could use – though I couldn't make it happen.

    @Icebox – RThurman has said that I should try your method to achieve my outcome. I've looked at your example but can't see how I can. Could you please take a look at my post just up the page a bit to see my grab. It hopefully demonstrates what I've been trying to do.

  • Village IdiotVillage Idiot Member, PRO Posts: 486

    @Icebox – I'm struggling to understand why you've got the spawn Direction rule in the "otherwise" section. I know it works – I just can't figure out why isn't in the section where it says "Drag your behaviours here".

  • IceboxIcebox Member Posts: 1,485
    edited August 2017

    @monkeyboy simian
    every 0.8 seconds
    spawn an actor called direction

    This would work fine , but think about it , we will spawn an actor every 0.8 seconds , imagine how many actors will be spawned after couple of minutes. We only need one actor at that spot not 142421523532 , so to avoid that I wrap it in a rule , the logic goes like this

    if overlaps or collides with "actor_direction" ( if the actor exists on that spot that im supposed to spawn it at)

    then
    Don't do anything I don't want to spawn the same actor again , I left this blank

    Otherwise
    if the actor does not exist on that spot , I did not spawn it yet , spawn actor "actor_direction" .

    Simple logic to avoid spawning multiple actors at the same spot , there might be better ways to do it but i thought this was quick and simple.

    Hope this made sense

  • Village IdiotVillage Idiot Member, PRO Posts: 486

    ok @Icebox .. let me see if I've got this.

    The leader actor is told to spawn the direction actor for the sole purpose of being in the way of the follower actor.

    The follower actor then is instructed to rotate 120° whenever it overlaps or collides with the direction actor.

    The .8 seconds determines when the leader actor (and the follower, in turn) rotate 120°.

    Also, just wondering how you arrived at .03 seconds for the follower to rotate. I experimented with that number and got some weird outcomes.

  • IceboxIcebox Member Posts: 1,485
    edited August 2017

    @monkeyboy simian said:
    Also, just wondering how you arrived at .03 seconds for the follower to rotate. I experimented with that number and got some weird outcomes.

    When you spawn the actor direction , it is spawned at the centre of the leader actor , but when the follower actor collides with it, it will collide with it as soon as it touches it, so the collision detection will trigger the code and it will rotate a bit earlier , this is why you will notice weird outcomes .

    In order to fix that i added a timer , a way to tell it don't start rotating as soon as you touch it , I want the follower to match the leader's path , so maybe a couple of frames ahead.

    Gamesalad runs your game at 60 frames per second , so when im experimenting with small delays i usually put 0.03 which means every 30 frames. This is just from experimenting it could have been any other value , I just saw that triggering the code after 30 frames made it follow the path of the leader actor perfect.

    To know how long it takes in seconds you can do the math

    10 frames per second = 0.01 frames per millisecond
    20 frames per second = 0.02 frames per millisecond
    30 frames per second = 0.03 frames per millisecond
    40 frames per second = 0.04 frames per millisecond
    50 frames per second = 0.05 frames per millisecond
    60 frames per second = 0.06 frames per millisecond

    You can experiment with 0.01 , 0.02 , 0.03 , 0.04 , 0.05 , 0.06 , you will notice different behaviours each time , but you will understand how and why things are not working the way they should.

    Hope I didn't confuse you with this , this is not the best way to do it. But this is how programming is , you will always find different ways to do things. If i wanted to do it myself i would spend days trying to look into all of the possible ways i can come up with and decide which works the best. So think of this method as a possible way to do it , not the most efficient.

  • Village IdiotVillage Idiot Member, PRO Posts: 486

    Thanks @Icebox – It doesn't take much to confuse me, so it's not you, it's me. This stuff doesn't come naturally to me – I just naively thought that I'd like to make games thinking it was going to be straight forward. I'll keep plugging away though – I'm hoping that eventually some of this will sink in.

  • Village IdiotVillage Idiot Member, PRO Posts: 486
    edited August 2017

    @Icebox @RThurman – I've tried both of your methods to achieve my goal and it seems like it's not going to work. Icebox I've just finished working with your demo and I've noticed that the follower actually appears to lose time and lag after about 30 seconds or so. Am I trying to do the impossible here?

    I'm trying to get a whole line of actors looking like this grab, all moving around. I've spent a lot of time on both methods and neither one seems to be able to do it the way I'm hoping to do.

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

    I guess I am not following what you want. So I will ask some questions.

    1) Do you really want an actor to follow another actor around?

    2) Or do you want a bunch of actors to move in a triangular pattern? (Each starting at a different spot on the triangles path?)

    3) Do you want some actors (in a triangle shape) to blink off and on so that it gives a movement effect? (Like a triangle shaped marquee?)

    4) Are you looking for something else?

  • Village IdiotVillage Idiot Member, PRO Posts: 486

    @RThurman – I guess, once the distinction is made as you have, it seems more like option 2.

    My original goal wasn't necessarily the idea of any actor following another actor – more accurately (I think now), I was going for a bunch of actors moving in a triangular pattern (as you put it in option 2).

    I'm thinking that I probably just didn't describe my idea accurately to begin with. I did have the idea of making this happen with other shapes i.e: squares diamonds etc.

    Sorry if I didn't get it right at the start – I think I could've done a better job there.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited August 2017

    @monkeyboy simian

    Maybe look into SuperShapes. Formulas are easy to be found on the web.

    That should give you a lot of creative freedom.

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

    @monkeyboy simian said:
    @RThurman – I guess, once the distinction is made as you have, it seems more like option 2.

    My original goal wasn't necessarily the idea of any actor following another actor – more accurately (I think now), I was going for a bunch of actors moving in a triangular pattern (as you put it in option 2).

    I'm thinking that I probably just didn't describe my idea accurately to begin with. I did have the idea of making this happen with other shapes i.e: squares diamonds etc.

    Sorry if I didn't get it right at the start – I think I could've done a better job there.

    Hey -- no problem. Its fun to explore different ideas. (But sometimes hard to describe exactly what you want.

    Here is an example of moving actors in a triangular pattern (but can be extended to all sorts of patterns.

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

    @Hopscotch said:
    @monkeyboy simian

    Maybe look into SuperShapes. Formulas are easy to be found on the web.

    That should give you a lot of creative freedom.

    Great idea! I was just about to build the same thing for an example! (Great minds think alike -- I guess.)

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited August 2017

    @RThurman said:
    Great minds think alike -- I guess.

    I wish I had your fluency in higher math!

    But yes, from @monkeyboy simian 's description, a good math approach could open it up for all kinds of dynamic content.

    I am very keen to see what the actual game play mechanic is!

  • Village IdiotVillage Idiot Member, PRO Posts: 486
    edited August 2017

    wow @RThurman and @Hopscotch – That looks like what I'm aiming for! I just did a bit of a google on SuperShapes and my brain melted. I liked the look of that demo video you put up. Is there a way that someone who's mathematically challenged could apply this? Thanks for the demo RThurman – I'm tinkering with it at the moment. This looks like it'll work too.. I have no idea how you guys can work out the positions of these things and move them around using the less than symbols.. sigh.

Sign In or Register to comment.