Your ball does not seem to have smooth moving implemented for it.
it's implemented. Is it possible to send you the project and you can take a look? Maybe you'll find what I did wrong. I spent sooo many hours just for this and it's still not working 100%
it's implemented. Is it possible to send you the project and you can take a look? Maybe you'll find what I did wrong. I spent sooo many hours just for this and it's still not working 100%
Just uploaded the scenario! Hope you can take a look
One thing that may be causing issues is that you have most of your players' behavior in a different class -- namely, the steuerung class. It would take a bit of doing, but it would be worth it to get rid of that class and put code in the players" classes. In fact, you can combine both player classes into one class -- same goes with the lasergoal classes. The less you have to work with, the easier it will be to code.
Another thing that you can do without are your try-catch phrases. The is nothing in your project (as yet) that you can not explicitly rule out. That is to say, a simple check can be performed prior to any command you execute to ensure no exceptions will be thrown.
okay I can make a players class and put the code from "Steuerung" into it but why should it change or fix the bounces?
I never said it would automatically fix the bounce. It just makes things a whole lot easier to work with -- everything in one place where it belongs and not copy/pasting to multiple classes.
What I mean by a single player class is a Player class that extends SmoothMover with no sub-classes -- and the ball should be the only other SmoothMover extension. Similarly, one LaserGoal class. No player1 player2, laserGoal1 or laserGoal2 class.
You still do not have it where no contact (in range) between the player and ball is (somewhat) guaranteed after a player moves. There must be separation between the two after any move by any object. At least an attempt at separating them must be made. It is possible that the ball could be squeezed between two players and it will "spit" out somewhere (like a fight for control of the ball), just with ball bounce and player push..
You still do not have it where no contact (in range) between the player and ball is (somewhat) guaranteed after a player moves. There must be separation between the two after any move by any object. At least an attempt at separating them must be made. It is possible that the ball could be squeezed between two players and it will "spit" out somewhere (like a fight for control of the ball), just with ball bounce and player push..
What do you mean with your post? What do I need to change?
I'm still figuring out how to make perfect bounces and actually I only have 5 days left until I have to be finished with this project so I hope I'll find a clean solution very soon
What do you mean with your post? What do I need to change?
If I recall, you have yet to check for an intersecting ball when a player moves. And when found, create a separation.
I'm still figuring out how to make perfect bounces and actually I only have 5 days left until I have to be finished with this project so I hope I'll find a clean solution very soon
Getting the above done will be a big part of fixing the bounce.
Use setLocation or move so that the two actors are no longer intersecting. Do it to the actor of your choice (the intersecting ball or the player). I would suggest re-positioning the ball so that it appears that the player has some control over where it goes.
That would probably looks really strange because the ball will teleport to a another location. Which location?
How should this look like a clean bounce?
That would probably looks really strange because the ball will teleport to a another location. Which location?
How should this look like a clean bounce?
Just move the ball as much and in the same direction as the player moved to cause the collision. Then, when the ball moves, it will either bounce (if it was moving toward the player) or it will continue on its way (when the player stops moving it). Even if the ball bounces, the player is faster and may continue to push it and it may not appear to actually have bounced; but, the change in directional movement of the ball will always be away from the player when consecutive collisions stop occurring.
Damn English makes it sooo hard for me to understand this , sry .. is it possible to provide me a piece of code so maybe I can understand better what you mean ?