Left right movement jamming.
Zebadey
Member, PRO Posts: 8
Hi all, noob question so apologies if I seem a bit thick. I have created a basic left right touch activation on my first test project. Created it with two Boolean game attributes , which turn true on touch with an else statement to switch them back to false if not touched. This seemed to work at first but the attributes started to stick on intermittently in game whilst using viewer on iPad and iPhone. Any help appreciated in solving this
Comments
Can you post a screenshot of your rules? It's much easier to help if we know exactly how you've set things up.
Mental Donkey Games
Website - Facebook - Twitter
Thanks for quick response, here are the rules for the right move, which is duplicated for the left
@Zebadey
I usually do my movement this way ,
2 game attributes Right and left booleans
2 actors for right and left
If touch is "inside"
game.Right is true
Otherwise game.Right is false
If touch is "inside"
game.Left is true
Otherwise game.Left is false
Try it I hope it works, there might be better ways but this works well for me.
Edit: when you put the movement rules " inside " it gives smoother control.
In your actor you can put it this way
If game.right and game.left is false constrain motion linear velocity to 0
Otherwise create two rules
if game.right is true constrain motion linear velocity x to the number you prefer
If game.left is true constrain motion linear velocity x to negative the number you prefer
What @Icebox said. Use "Otherwise".
If touch is pressed
Attribute "LeftButtonPressed" = true
Otherwise
Attribute "LeftButtonPressed"= false
End If
My Blog / App Store / Google Play
@mhedges The problem with using pressed in movement buttons is that when you switch from right to left it sometimes gets stuck , so its better to use inside , cause some people swipe their finger tips to both sides instead of releasing the button. This happens more with movement touch buttons only , so using when touch is inside is much better.
Correct - I overlooked that focusing on the "otherwise".
My Blog / App Store / Google Play
Thank you all , solved it straight away. Wow you guys are good
Also note you don't need that rule in the otherwise section. All you need is the change attribute this is why it was getting stuck. Touch is released is a permanent condition once executed unlike pressed, which is a momentary condition. So by removing the release rule you set that rule up like a switch.
So if pressed condition will be true. If not pressed the condition will become false. The released rule messes with that process.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
You can do this with a very straightforward rule . . . in your actor's Motion attributes set the LinearVelocityX to 200, then have a simple rule that says:
When touch is pressed
Change LinearVelocityX to -LinearVelocityX