How to constrain one actor to another without lag?
samwessley
Member Posts: 2
I'm having some problems with what would seem like a very simple thing to do. I have 5 actors that are supposed to move left or right as one solid piece when I press the left key or the right key. For one of the five actors I have these rules:
Rule 1: constrain attribute: game.PositionX to self.position.x
Rule 2: when left key is pressed: move left at a speed of 300
Rule 3: when right key is pressed: move right at a speed of 300
The other 4 actors have 1 rule: constrain attribute: self.position.x to game.PositionX
This seems like it should work but when I press left or right there is a delay to the other 4 actors. All the actors have a density, friction, and bounciness of 0 so that isn't the problem. Is there a way to fix this?
I have also tried:
— Adding the move left and move right rules to the other 4 actors, but they become unaligned when you make quick maneuvers so I can't do it that way.
— Constraining the 4 actors to the first actor's x position vs the game.PositionX, which still results in the same lag.
Any help would be greatly appreciated since this is preventing me from finishing my app.
Rule 1: constrain attribute: game.PositionX to self.position.x
Rule 2: when left key is pressed: move left at a speed of 300
Rule 3: when right key is pressed: move right at a speed of 300
The other 4 actors have 1 rule: constrain attribute: self.position.x to game.PositionX
This seems like it should work but when I press left or right there is a delay to the other 4 actors. All the actors have a density, friction, and bounciness of 0 so that isn't the problem. Is there a way to fix this?
I have also tried:
— Adding the move left and move right rules to the other 4 actors, but they become unaligned when you make quick maneuvers so I can't do it that way.
— Constraining the 4 actors to the first actor's x position vs the game.PositionX, which still results in the same lag.
Any help would be greatly appreciated since this is preventing me from finishing my app.
Comments
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Make sure the master actor (the one giving it's X position to 'attribute:game.PositionX') is beneath all the other four in the the layers panel.
Attached are two GS files.
The first one is 'wrong order' - the layers are arranged like this:
1
2
3
4
5
You can see a lag between the master actor '1' and the other four.
. . . . . .
The second one is 'right order' - the layers are arranged like this:
5
4
3
2
1
The lag is gone.
>-
Thank you that solved it! I'm glad it was as simple as that and not some complicated fix. You saved me a lot of time!
No problem.
I'm not trying to be a troll here, nor am I trying to hijack a thread (since it's probably finished), but I feel compelled to comment on how pleasant this thread was to read. For me this was the perfect discussion, and could be held up as an example of how to conduct a discussion within the GameSalad community. This discussion was simply a pleasure to read!
Why, you ask? Well... let me explain.
First, rather than making a disparaging comment about GameSalad's (self perceived) shortcomings (which is almost always done to cover up one's own inability to admit to personal failure), the OP demonstrated that he had done due diligence in working out the issue. He:
--a) clearly described the effect he was trying to achieve,
--b) explained in detail what he was currently doing,
--c) included the rules/behaviors he used (but that didn't seem to work),
--d) described past attempts that didn't seem to work either
--e) postulated that (logically) his solution should have worked and that he might be missing a fundamental aspect of the way GameSalad works.
This really helped him get a fairly swift and accurate answer.
In addition (probably because he did such a good job setting up the problem), all of the responders answered in a helpful way with insights they had gained as they worked on the same kinds of issues.
-- a) There was no complaining about the OP whining.
-- b) There were no smart-alic remarks about how the OP should man-up and do his homework.
-- c) There was no bragging about how 'I learned GS and am now a (self-proclaimed) guru of GameSalad'.
-- d) And there was no one griping about the braggart who is complaining about the whiner. (Hmm... the griper in this thread would be me -- right now -- sorry about that!)
Lastly, two essential aspects of GameSalad were revealed:
--a) GameSalad Creator may not accurately represent what will happen on the end device. (After all Creator runs on a mac which has a completely different architecture than a mobile device.)
--b) GameSalad works in layers, and the actors in each layer get a turn to fire their rules in a predictable manner. It starts with the actors in the bottom layers and works up to the top layer. This is fundamental to GameSalad's architecture, and almost everyone seems to ignore its implications. Gamesalad works in an orderly manner. The order that actors (and their rules) fire is perfectly predicable!
(Right about now everyone should hear angelic music and a shaft of light should descend upon them as a fundamental mystery of GameSalad is revealed.)
So... thanks to the OP and the responders. Its great to learn about GS and its great that there are helpful individuals who volunteer their talents to make this a terrific community and forum.
Note: Too bad this discussion has only 38 views and will likely sink into oblivion in the next few hours.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Yeah, I think the storm has passed. It's quite tranquil a the moment, which is good for everyone.