jerky movement after a push
Hi,
I have one object (my player) pushing another, like a player pushing a box in sokoban. Once I move away and stop pushing the box, its continues to jerk around a little bit. One pixel here, one pixel there...
I have it stop its overall movement by using a high drag on the box but it still jerks about.
How can I stop this, so when I stop pushing it, it just stops completely in place with no further movement?
Thanks
Jamie
I have one object (my player) pushing another, like a player pushing a box in sokoban. Once I move away and stop pushing the box, its continues to jerk around a little bit. One pixel here, one pixel there...
I have it stop its overall movement by using a high drag on the box but it still jerks about.
How can I stop this, so when I stop pushing it, it just stops completely in place with no further movement?
Thanks
Jamie
Comments
make a rule in the box when object collides with player,
now dont put anything in the rule, open up the otherwise section of it.
In the otherwise section do this:
change attribute self motion linear x to 0
change attribute self motion linear y to 0
that will tell it when the player is not colliding with the box, the box will stop all its movements. Try that out and see if it helps.
That is a great 'trick' to leave the rule blank and use the otherwise section for 'when not colliding'. I had looked for a function or something like that and never thought of trying this out.
Thanks again!
Jamie
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
In case anyone is looking at this topic for help, I found a better way to accomplish stopping the box completely. After play testing the method discussed above it was not 100% effective and still drove me nuts to see the box moving around a bit after I stopped pushing it.
Here is a better way, seems 100% so far.
1. For the box add two new 'real' attributes. Add a selfY and a selfX.
2. Add a rule to the box just like JohnPapiomitis says above.
3. Set the rule up so when the actor received the overlaps or collides event with the main character.
4. Leave the immediate section below blank.
5. In the 'otherwise' section of the Rule add a Change Attribute behavior changing "self.selfY" (one of the new attributes I added) to "self.Position.Y". That is the Y position of the actor.
Add Constrain Attribute behavior constraining the "self.Position.Y" to "self.selfY".
Then repeat for the X values. This will keep the box actor locked/sitting still at its last X and Y values.
If a video or screen grabs would help, let me know.
Hope it helps someone in need.
Jamie
www.jamie-cross.net
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page