Make paddle follow ball but slower?
sSHAKESs
Member Posts: 27
Hello, guys!
I'm really having trouble making my paddle follow the ball slowly. The paddle follows the ball with no problem... but since it's constrained to it's position, it always catches the ball. I want the paddle to move slower than the ball so I can just adjust it with a difficulty level. I tried interpolate but it only works on the first serve... after that it doesn't follow the ball anymore. =(
Please help.
I'm really having trouble making my paddle follow the ball slowly. The paddle follows the ball with no problem... but since it's constrained to it's position, it always catches the ball. I want the paddle to move slower than the ball so I can just adjust it with a difficulty level. I tried interpolate but it only works on the first serve... after that it doesn't follow the ball anymore. =(
Please help.
Comments
have you tried constraining with an offset?
Constrain Attribute/ self.position.x to BallX-50 (or any other numbers)
Well, I have constrained the paddle to the ball's movement. So, it follows it exactly. But then, that would mean the cpu would be unbeatable. So, I want to adjust the paddle's speed when it's following the ball. I want it to be slower.
I tried offsetting it but it looks unnatural. And if I offset it like so, then it would always not catch the ball. I tried adding interpolation but it only works on the first serve. It doesn't work anymore once it returns the ball... the paddle just stops.
When game.ballY < self.Position.Y-10
--Change Attribute: self.Motion.Linear Velocity.Y To: -100
Otherwise
--Change Attribute: self.Motion.Linear Velocity.Y To: 0
When game.ballY > self.Position.Y+10
--Change Attribute: self.Motion.Linear Velocity.Y To: 100
Otherwise
--Change Attribute: self.Motion.Linear Velocity.Y To: 0
Also, If you get rid of the two 'otherwise' behaviors, the paddle will do a kind of anticipatory dance that might add some character to it.
- So my game is in portrait mode so I changed all to the X axis.
- I then constrained the game.ballX attribute to the ball.
- And did as you listed in the paddle.
1) You can't copy and paste the attributes. You need to get them from the drop-down menus.
2) You will need to replace "game.ballY" with the attribute you are using to save the position of the ball. ("game.ballY" was only meant to give you an idea that you need to have a game-level attribute that records the ball's Y position.)
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Sigh... this is sorta frustrating. I'm sorry for being such a newbie.
1. Yep. I know I can't copy and paste.
3. Yes. I did constrain the 'game.ballY' to the ball's position. I am using a different attribute name.
@FryingBaconStudios
I can never get the 'move to' behavior to work. So can I just put 'game.ballY' in the X Position of the 'move to' behavior? That's what I did and it doesn't move.
Push:
http://www.mediafire.com/download.php?0tq004ybz4yaulg
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Okay, don't kill me... but I found out why it wasn't working before... the paddle wasn't MOVABLE! Grrrrr!!! So... what you gave me works now!!! I'm so happy! Thanks so much!!!
Only problem now is that when the ball goes in the goal, or the ball's not in the court, the paddle is moving from left to right because it's waiting for the ball.
Like what @FryingBaconStudios said, how do I make it move back to a default position when the ball is in the goal or when it's waiting for the next round?
The next issue seems like a completely different topic. It sounds like its time to make a new thread and ask how to move a paddle back to its starting position once the ball is out of play.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS