Spin a group as a single object?

Hi, I'm evaluating different game building apps to make a game I recently conceived. A major part of this game would involve a rotating planet, with objects that stick to the planet when they collide with it and then from that point rotate as part of. So I'm looking for some kind of function that can either make objects stick together and be rotated as a group, or else a behavior that will make one object rotate around another object or (worst-case) make an object rotate around a point on the screen. After my first few hours of digging I am not finding this as an obvious feature in GameSalad. Can anyone point me to such a feature, or any kind of library/code for customizing it if necessary?
«1

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I'm not sure if this will make much sense to you but @Socks has a brilliant Link Machine that will link objects together in that way.

    http://forums.gamesalad.com/discussion/62202/linkmachine

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

  • x2501xx2501x Member Posts: 11
    Thank you for the quick reply. I may be wrong, but I don't think that will work, because it appears that you have to set up those connections when you build the game. The entire process of the game I'm working on is that the child objects would become attached to the parent on the fly, in whatever spot where they touch each other. Also, though I read the description on that page you linked, the demo video appears to have been removed from YouTube.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    True, the video is missing, but the download link still works: https://us.v-cdn.net/5017598/uploads/FileUpload/de/da9bbf13cb33ddbb3e14c50db46187.zip.

    You can link objects (aka actors) "on the fly" but it's a complicated process to code. An example of this, though not one that rotates, is my health bar demo: http://forums.gamesalad.com/discussion/comment/384027/#Comment_384027.

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    Thank you for the quick reply. I may be wrong, but I don't think that will work, because it appears that you have to set up those connections when you build the game.
    There is nothing in GameSalad that says a rule needs to happen at a certain point, you can get your bounce animation or rotation behaviour or actor fading to black or constrain behaviour or sound of a car exploding (etc etc) to happen whenever you like.

    If you set up a rule that says when the player touches the 'cookie actor' it cries (don't steal my ideas) then just because you've set this up when you build the game doesn't mean you can't then have it happen throughout the game wherever you like . . . . it's the same deal with using a rotate or constrain behaviour, you can get then to 'switch on’ when you want.
    Also, though I read the description on that page you linked, the demo video appears to have been removed from YouTube.
    I that knew when I reposted the video in that thread that unless it was in the initial post people wouldn't scroll down to find it :)) pity there's no way of editing your original post in a thread, I must have had 5 or 6 people message me for that video even though it's right there in the thread.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I must have had 5 or 6 people message me for that video even though it's right there in the thread.
    Well, but... reading.

    Anyway, it's fixed now @Socks .

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

  • SocksSocks London, UK.Member Posts: 12,822
    I must have had 5 or 6 people message me for that video even though it's right there in the thread.
    Well, but... reading.

    Anyway, it's fixed now @Socks .


    Magic ! Cheers @tatiang

    :)>-
  • x2501xx2501x Member Posts: 11

    There is nothing in GameSalad that says a rule needs to happen at a certain point, you can get your bounce animation or rotation behaviour or actor fading to black or constrain behaviour or sound of a car exploding (etc etc) to happen whenever you like.
    OK, I was only going off the text of your post. Everything you explained was based on using that tool to figure out values when setting up a scene. Since there was no mention of a method for doing it on the fly, I assumed that meant there was not one. In particular, the relationship of a child object to the parent object in my game would not be known *until they collided*, which means that any pre-calculation as you described would not be possible.

    I still don't understand GameSalad well enough to have found this on my own so I will ask--is the actual control of the constrain behaviour part of your "link machine", or is Link Machine only the tool show in the video for setting up the relationships, and the constraints are things built into GameSalad itself?
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    @x2501x
    OK, I was only going off the text of your post. Everything you explained was based on using that tool to figure out values when setting up a scene.
    I'm not sure I recognise the distinction, I'm not sure what the difference would be between figuring out a rule when you set the scene up or otherwise ? Isn't everything part of setting a scene up, sorry I'm a little confused by what you mean here ?
    Since there was no mention of a method for doing it on the fly, I assumed that meant there was not one. In particular, the relationship of a child object to the parent object in my game would not be known *until they collided*, which means that any pre-calculation as you described would not be possible.
    Again, I'm a little confused, doesn't take much to confuse me sometimes :)) I have no clue what a 'pre-calculation' might be with respect to GameSalad ? Unless I'm missing something here, if you want something to happen when two things collide then have the rule operate when they collide !!?
    I still don't understand GameSalad well enough to have found this on my own so I will ask--is the actual control of the constrain behaviour part of your "link machine", or is Link Machine only the tool show in the video for setting up the relationships, and the constraints are things built into GameSalad itself?
    The Link Machine is just a calculator of sorts, stick two objects in a certain spatial relationship and it will tell you the three constrain behaviours you will need to make them stick together like that.

    GameSalad has constrain behaviours built into its rule set, once you've used this 'calculator' to work out the numbers you need to put into the constrain behaviours it plays no other role.

    Hope that all makes sense.
  • x2501xx2501x Member Posts: 11

    Again, I'm a little confused, doesn't take much to confuse me sometimes :)) I have no clue what a 'pre-calculation' might be with respect to GameSalad ? Unless I'm missing something here, if you want something to happen when two things collide then have the rule operate when they collide !!?
    Sorry if it's confusing, let me try to be more clear. It's not about the *rule*, it's about the specifics that make it work. Your post says that the relationship for how an object is placed/angled/orbits around another object is complicated, so you built the LinkMachine in order to generate the correct numbers to make that work properly. Using the LinkMachine involves vary carefully placing and rotating the child object into just the right spot relative to the parent and then taking the numbers it generates and plugging them into some constraining behaviors.

    What I'm saying is that I would need to *calculate those numbers* in the game, not ahead of time. Imagine, based on your own example, that your police car was spinning around, and someone threw a sticky siren/light at it, which might hit the police car at any point, and might be at any angle when it hit it, but *from then on* it would move and rotate as if it were solidly stuck to the police car, staying at the same distance and relative angle to the car as the car itself turned and moved. That's the problem I'm trying to solve.

    I hope that makes it more clear? I guess I'm just finding things frustrating because I am used to working with 2d animation apps like Motion or Premiere, where you can just take a group of objects and set them to be a group with a specified center of motion, and then rotate them all around that center with a single action. As a backup I had been searching in GameSalad for some way to specify the center of rotation for an object to see if there is a way to offset that outside the dimensions of that object? That is, forget for a moment the idea of even sticking two things together, is there a way to set the center of rotation for a single object around a point outside the boundaries of the object?
  • 3itg3itg Member, PRO Posts: 382
    @Socks has given you the solution, but stopped just short of typing it into gamesalad for you.
    wait... no, he did that too...

    Make three attributes.
    real "Orbit",
    angle "Rotation"
    and
    real "Radius".

    You can then use Constrain, or Change, or Interpolate to "calculate those numbers" in the game... and not ahead of time.

    when the actor collides with the planet, you might want to try recording its position in relation to the planet in a couple self.attributes and use them so the object can reference where it collided with the planet. For example, you could use magnitude to determine the radius.
    When overlapping or colliding with object
    change self.radius to magnitude(self.position.x-planetposition.x, self.position.y-planetposition.Y)
  • x2501xx2501x Member Posts: 11
    OK, I think I have figured out the piece I didn't yet get, and probably why you all are treating me like I'm a moron. Because I haven't yet gone through enough working with GameSalad, I didn't yet download the .zip file in that post to try it out. So I'm guessing that the key is that @Socks has written behaviors that will handle the actual orbiting/constraining rotation, which need to be copied out of his sample game and into whatever project wants to use that functionality? From reading the description several times through (and because I am new to GameSalad) I had the impression that he was saying to take the numbers generated from the LinkMachine and plug them into some *already existing* feature of GameSalad, but no one was actually saying what that feature was.

    So, is that correct--once I have a bit more of a handle on the workings of GameSalad and grab that zip file, the behaviors for Orbit, Rotation and Radius are contained in that project? I'm sorry I guess my assumption was that since the demo video *only* showed off the function for generating the numbers, that was the only part that @Socks had created.
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    I don't think that will work
    I had the impression that he was saying to take the numbers generated from the LinkMachine and plug them into some *already existing* feature of GameSalad, but no one was actually saying what that feature was.

    :) The feature is . . . . . . 'constrain', read through the instructions provided:
    This is how it works:

    1) In the project you have a parent object and a child object.
    2) You use three sliders to position the child actor in relation to the parent actor.
    3) When the child actor is in position you press the 'code' button which generates your code (three constrains behaviours).
    4) You go back to your own project and place your own child actor in your scene and unlock it (so it can see the parent actor's values)
    5) Then add three constrain behaviours to your 'child' actor and enter the values generated by the LinkMachine™
    OK, I think I have figured out the piece I didn't yet get, and probably why you all are treating me like I'm a moron.
    I think that's a little unfair, people are trying to help you here, it's sometimes difficult to fight against a 'no, that's not going to work' defeatist attitude to suggestions, especially when coming from someone who admits to being new to GameSalad, and especially knowing that these suggestions work just fine.
  • x2501xx2501x Member Posts: 11
    edited February 2014

    :) The feature is . . . . . . 'constrain', hopefully I was clear enough, read through the instructions provided:
    This is how it works:

    1) In the project you have a parent object and a child object.
    2) You use three sliders to position the child actor in relation to the parent actor.
    3) When the child actor is in position you press the 'code' button which generates your code (three constrains behaviours).
    4) You go back to your own project and place your own child actor in your scene and unlock it (so it can see the parent actor's values)
    5) Then add three constrain behaviours to your 'child' actor and enter the values generated by the LinkMachine™
    But this seems to say that the key is the "three constrain behaviors", which I *think* you created, right?

    That is, I have poked around in several places and searched through the online documentation and I see no mention of the word "radius", which makes me think that is not something that is a built-in behavior in the game?
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    But this seems to say that the key is the "three constrain behaviors", which I *think* you created, right?
    I haven't got a clue what that means. 8-X
    That is, I have poked around in several places and searched through the online documentation and I see no mention of the word "radius", which makes me think that is not something that is a built-in behavior in the game?
    Yes, that's right, there is nothing within GameSalad (as far as I know) that references the word "radius".
  • x2501xx2501x Member Posts: 11
    Let me try to ask this a different way, then.

    What is the "radius" constrain behavior? I have looked at the "Constrain Attribute" behavior built into GameSalad, and I see nothing that maps to "radius". So, if I create a constrain behavior and *name it* "radius", how do I actually make it *do something* that has to do with constraining a radius? My presumption from reading your instructions was that you had built a custom behavior named "radius" that does something, but now you're saying you don't have a clue what I mean.
  • natzuurnatzuur Member Posts: 304
    Lol this thread is getting confusing. This is a bit of an undertaking for someone new to GS to be sure.

    Behaviors are essentially predefined code that can serve multiple purposes. A constrain does exactly what it says. It constrains an attribute to a value (or another attribute, so any given variable).

    This is very useful for joining two objects. Such as a rock and a planet. On the simplest level you could make an x and y attribute for the planet (integer or real) and, let's call them PlanetX and PlanetY and then say:


    Planet Actor:
    Constrain PlanetX to Self.positionX
    Constrain PlanetY to Self.positionY

    Rock actor:

    When touch is pressed:
    Constrain Self.positionX to PlanetX
    Constrain Self.positionY to PlanetY

    What this does is globally advertises the position of the planet actor so that the rock actor can pull that information and know where to lock to. In this case, this would allow you to constrain it to x and y position.

    However what you're asking for is a bit more complex because it requires you to find more then just a pixel position. Thus this is where @Socks Linkmachine comes in. He has created some triginometric equations to take information passed (x/y/rotation) and make a more complex relationship.

    While not every aspect of the project is what you need, it does provide the means for creating the relationship of actor
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    What is the "radius" constrain behavior?
    I don't know !? Sorry, I feel like I'm being difficult now ! Lol, honestly I'm not, I guess I'm a little thrown by your questions . . . I don't know what the radius constrain behaviour is, nor where you've gotten the concept or term.
    I have looked at the "Constrain Attribute" behavior built into GameSalad, and I see nothing that maps to "radius".
    Yes, the Constrain attribute just tracks a value, anything you want, you can constrain the width of an little alien actor to the length of time a clock has been running - or the colour of your score display to the position of your finger on the screen - or the direction of an spinning arrow to what angle you are holding your iPad at . . . . etc etc, it's just used to have one thing use a value from another thing - a common one would be an actor following the position of your finger on a touch device.

    Like you say there is nothing that 'maps' to 'radius' (I'm not even sure where you were looking to see what maps to radius ?), nor is there anything that maps to 'alien width' or 'score colour' or 'arrow direction' . . . and so on, it's just an 'empty' behaviour looking for you to tell it what to do.
    So, if I create a constrain behavior and *name it* "radius" . . .
    I'm not sure you can 'name' behaviours (in any meaningful way at least), do you mean change the title in the behaviour's title panel ?
    how do I actually make it *do something* that has to do with constraining a radius?
    Well, that's a difficult question to answer as it is so vague, you'd need to be a lot more specific.
    My presumption from reading your instructions was that you had built a custom behavior named "radius" that does something, but now you're saying you don't have a clue what I mean.
    Yes.
  • x2501xx2501x Member Posts: 11
    @natzurr... I feel like I'm asking clear questions and then getting answers that don't make sense. And then when I try to figure out what I might be misunderstanding, I keep being told that it made sense in the first place... because it does.

    I *understand* what "constrain" means. I get that. But there is no built in "radius" attribute to constrain to something. And so as I said, my assumption was therefore that @socks had made a custom behavior that *effectively* constrains the orbit and radius, but when I asked if that was the case, he said no. Can you see why I might find this frustrating? If *neither* of those is the case, then what *is* the case? Where do the "orbit" "radius" and "rotation" constraint behaviors *come from*?

  • SocksSocks London, UK.Member Posts: 12,822
    @natzuur
    However what you're asking for is a bit more complex because it requires you to find more then just a pixel position.
    It's still just two coordinates ! It's still just X and Y, that's all sin and cos are ! Cos is how far left and right something is, sin is how far up and down something is !!

    It's much simpler than people often think.
  • natzuurnatzuur Member Posts: 304
    edited February 2014
    @natzuur
    However what you're asking for is a bit more complex because it requires you to find more then just a pixel position.
    It's still just two coordinates ! It's still just X and Y, that's all sin and cos are ! Cos is how far left and right something is, sin is how far up and down something is !!

    It's much simpler than people often think.
    True, but not knowing how attributes behave and then jumping into trig can be daunting!

    Essentially what your looking for @x2501x is this

    Constrain Self.position.X to radius*cos(PlanetRotation)+PlanetX
    Constrain Self.position.Y to radius*sin(PlanetRotation)+PlanetY
    Constrain Self.Rotation to PlanetRotation

    This will provide you the actor relationship you need. Like @Socks said Cos is for X Sin is for Y.

    Now to explain the variables:

    radius is just how far from the main actor you would like it, it can be a static number you type in or a attribute to change it on the fly/easier adjustment.

    PlanetRotation is a attribute used to track the rotation of the parent object

    PlanetX/Y are attributes used to track the pixel position.

    Of course these could be static values you type in as well, but it would'nt be very exciting without some movement/roation!

    Linkmachine expands on this with more variables for greater actor control.
  • SocksSocks London, UK.Member Posts: 12,822
    @natzurr... I feel like I'm asking clear questions and then getting answers that don't make sense.
    Your questions aren't particularly clear, interchangeable terms aren't helpful (what is a 'constrain attribute' or a 'constraint' or a 'radius constrain behaviour' ?? etc etc).
    And then when I try to figure out what I might be misunderstanding, I keep being told that it made sense in the first place... because it does.
    I can only speak for myself, but my answers have been consistent, I've not moved from a position of saying something doesn't make sense to a position of saying the same thing does make sense.
    I *understand* what "constrain" means. I get that. But there is no built in "radius" attribute to constrain to something.
    Yes, there is no built in "radius" attribute.
    And so as I said, my assumption was therefore that @socks had made a custom behavior that *effectively* constrains the orbit and radius, but when I asked if that was the case, he said no.
    Yes, the answer is no, I've not made any custom behaviours, the project is simply a calculator, move the objects around and it will tell you what numbers you need to use in your project.
    Can you see why I might find this frustrating?
    I think you are just frustrated at not knowing your way around some basic concepts within GameSalad, no big deal, it's like that for all of us, but I wouldn't waste your time trying to attribute your own confusion to others.
    If *neither* of those is the case, then what *is* the case? Where do the "orbit" "radius" and "rotation" constraint behaviors *come from*
    "Why" *the* need "for" all the *asterixis* and "quotation marks", it just makes your posts harder to parse / scan ?

    There are no orbit, radius or rotation constrain behaviours, the constrain behaviour simply tracks one value to another, you can use it for anything you want.

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


    Essentially what your looking for @x2501x is this

    Constrain Self.position.X to radius*cos(PlanetRotation)+PlanetX
    Constrain Self.position.Y to radius*sin(PlanetRotation)+PlanetY
    Constrain Self.Rotation to PlanetRotation

    The only thing you'd also need in there would be an offset for the PlanetRotation . . . . so for instance if you have an incoming missile fired at the earth - it will hit in some arbitrary location . . . . you need to factor that in, otherwise all the missiles that collide with the earth and then are constrained to your rules will all end up in the same position, you'd need something like this . . . .

    Constrain Self.position.X to radius*cos(PlanetRotation+theAngleTheyHitAt)+PlanetX
    Constrain Self.position.Y to radius*sin(PlanetRotation+theAngleTheyHitAt)+PlanetY
  • natzuurnatzuur Member Posts: 304
    @natzuur


    Essentially what your looking for @x2501x is this

    Constrain Self.position.X to radius*cos(PlanetRotation)+PlanetX
    Constrain Self.position.Y to radius*sin(PlanetRotation)+PlanetY
    Constrain Self.Rotation to PlanetRotation

    The only thing you'd also need in there would be an offset for the PlanetRotation . . . . so for instance if you have an incoming missile fired at the earth - it will hit in some arbitrary location . . . . you need to factor that in, otherwise all the missiles that collide with the earth and then are constrained to your rules will all end up in the same position, you'd need something like this . . . .

    Constrain Self.position.X to radius*cos(PlanetRotation+theAngleTheyHitAt)+PlanetX
    Constrain Self.position.Y to radius*sin(PlanetRotation+theAngleTheyHitAt)+PlanetY
    True, oh and of course the logic to actually trigger the constrains as well.

  • SocksSocks London, UK.Member Posts: 12,822
    @natzuur
    True, oh and of course the logic to actually trigger the constrains as well.


    Yep, not really given that part much thought, but it's probably just a 'when actor overlaps or collides with 'Planet' rule . . . . . ?
  • x2501xx2501x Member Posts: 11
    @Socks:
    There is no text formatting that I can see on this forum. I am using asterisks for emphasis (in place of italics) and I was using quotations... because I was quoting words. Let me test something to see if HTML text tags will work.
  • natzuurnatzuur Member Posts: 304
    @natzuur
    True, oh and of course the logic to actually trigger the constrains as well.


    Yep, not really given that part much thought, but it's probably just a 'when actor overlaps or collides with 'Planet' rule . . . . . ?
    Yeah. So there you go @x2501x that's all the information laid out as simply as can be.
  • x2501xx2501x Member Posts: 11
    OK. I see that HTML tags will work, so I will not use asterisks for emphasis in the future.

    As for the source of my confusion--In your instructions, you say that LinkMachine controls three variables, Orbit, Radius and Rotation. Later, in your instructions, you say:
    Then add three constrain behaviours to your 'child' actor and enter the values generated by the LinkMachine™
    Can you see why it might make sense that I would assume the "three constrain behaviors" would, therefore, map to "Orbit", "Radius" and "Rotation"?
  • SocksSocks London, UK.Member Posts: 12,822
    @Socks:
    There is no text formatting that I can see on this forum. I am using asterisks for emphasis (in place of italics) and I was using quotations... because I was quoting words. Let me test something to see if HTML text tags will work.
    Ok, cheers, I didn't realise.
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    OK. I see that HTML tags will work, so I will not use asterisks for emphasis in the future.

    As for the source of my confusion--In your instructions, you say that LinkMachine controls three variables, Orbit, Radius and Rotation. Later, in your instructions, you say:
    Then add three constrain behaviours to your 'child' actor and enter the values generated by the LinkMachine™
    Can you see why it might make sense that I would assume the "three constrain behaviors" would, therefore, map to "Orbit", "Radius" and "Rotation"?
    Perhaps it's just a confusion of the language being used, or good ol' apophenia, three of one thing, three of another, there must be a connection, they are related, in fact they must be the same !! :)

    It's just a coincidence of kinds, they are related of course, but it's not a simple case of 1, 2 and 3 match 1, 2 and 3, one for 'orbit' one for 'radius' and one for 'rotation'. . . . one of the three constrain behaviours controls horizontal position of the actor, one controls the vertical position and one controls the rotation, so 'orbit' and 'radius' values are spread out across constrain behaviours 1 and 2 (x and y position), in fact that's all this really does, change the X and Y coordinates.

    The idea of the Link Machine was to simplify a commonly used and simple (if not always intuitive) bit of trigonometry, what the constrain behaviours are constraining is the X and Y position of an actor (and the rotation if needed). All the other stuff, the words 'radius' and 'orbit' and the coloured lines and circles are just visual and conceptual aids, a kind of translation of the underlying trigonometry, rather than telling people they need to offset the angle on which cosine and sine are operating in order to move the object to a different angle in relation to the parent actor, I just used the term 'orbit' . . . as in 'drag the yellow slider around to change the orbit position' . . . . you could have called it anything, 'radial position' perhaps, or 'moon position' or even use the numbers on a clock, 1 o'clock, 2 o'clock, 3 o'clock, 4 o'clock . . . and so on, and just like 'radius' or 'orbit' you'd have no luck searching for 'radial position', '8 o'clock' or 'moon position' in any GameSalad manuals or forum posts.

  • x2501xx2501x Member Posts: 11
    I appreciate people taking the time to actually explain the parts that weren't as obvious at first. It seems like it might actually be more simple than it seemed at first.

    My trig is a bit rusty, but for getting the values on the fly--
    Am I right to assume that at the point of collision, I can just calculate the radius on the fly by taking the square root of delta-X squared plus delta-Y squared (delta from the center of the planet), or is there some other factor I'm overlooking?

    And for the offset angle at initial impact, that would be X=tan-1(delta-Y/delta-X) ?
Sign In or Register to comment.