Constraining between 2 set points.
Okay, so this had been asked before but I never saw the response I really needed.
Probably quite simple but what I want to do is constrain something between 2 points on the y axis, for example 10 and 300, and then have it constrained to 1 singular point on the x axis meaning it can only go up and down between set values but not left and right. (For example a brick breaker app with the paddle at the bottom.)
The main reason most other methods have not worked is because when you press another part of the screen with them, the paddle just appears there, whereas I would like it to move to there, to increase the difficulty of the game, because it seems a bit tacky when it just appears wherever you touch it.
Hope you guys can help, thanks in advance,
Ross.
Probably quite simple but what I want to do is constrain something between 2 points on the y axis, for example 10 and 300, and then have it constrained to 1 singular point on the x axis meaning it can only go up and down between set values but not left and right. (For example a brick breaker app with the paddle at the bottom.)
The main reason most other methods have not worked is because when you press another part of the screen with them, the paddle just appears there, whereas I would like it to move to there, to increase the difficulty of the game, because it seems a bit tacky when it just appears wherever you touch it.
Hope you guys can help, thanks in advance,
Ross.
Best Answers
-
ORBZ Posts: 1,304
Ah yes, I forgot the limits:
Set bumpers where you don't want the paddle to go past.
Of course this may not work as I am just shooting from the hip and haven't tested it and I'm sleepy
The general idea is there though. you may have to tweak it -
ORBZ Posts: 1,304
Also how did you compute the distance? I was mistaken to suggest the Magnitude function before as I wasn't thinking through clearly.
just constrain y velocity to.position.y - touch.y
Answers
Constrain linear velocity y to difference between self.position.y and touchY