Using 'Interpolation' to replace 'Move To'
JackBQuick
Member Posts: 524
I have multiple actors, in different locations on my game board, that I want to move together.
Previously, I would use 'Move To'. For example, I could tell the actor to move 100 pixels vertically by assigning the value of 100 pixels to a global game attribute (called, say, 'distance'), and having all the actors read this attribute. In other words, they would each move to a spot that was: (self.Position.Y) + distance. If an actor's initial Y coordinate was 100, it would move to Y = 200.
When I try to do this with 'Interpolation', my actors fly off the screen. This is probably because 'self.Position.Y' gets updated every step along the way (so, after moving one pixel, the value becomes 201; after two pixels, 202; and so on, never reaching a final destination).
I have corrected this by creating an actor attribute (instead of a game attribute) and assigning to it: (self.Position.Y) + distance.
I'm applying this to two dozen actors at the same time. So, this method would require two dozen calculation. This works but is there a better way to achieve the same effect? I suspect there might be but I just can't see it. It's probably something very very simple...
Previously, I would use 'Move To'. For example, I could tell the actor to move 100 pixels vertically by assigning the value of 100 pixels to a global game attribute (called, say, 'distance'), and having all the actors read this attribute. In other words, they would each move to a spot that was: (self.Position.Y) + distance. If an actor's initial Y coordinate was 100, it would move to Y = 200.
When I try to do this with 'Interpolation', my actors fly off the screen. This is probably because 'self.Position.Y' gets updated every step along the way (so, after moving one pixel, the value becomes 201; after two pixels, 202; and so on, never reaching a final destination).
I have corrected this by creating an actor attribute (instead of a game attribute) and assigning to it: (self.Position.Y) + distance.
I'm applying this to two dozen actors at the same time. So, this method would require two dozen calculation. This works but is there a better way to achieve the same effect? I suspect there might be but I just can't see it. It's probably something very very simple...
Comments
OK, I noticed this too. It will be an issue every time you want to animate an attribute relative to the initial value. Will have to create loads of additional attributes, set them, and the 0.1s delay for the Interpolate behavior.
How about if it had an "Update during interpolation" checkbox or something like that?
PS. Hooray!!