Hello Guys,
I have been going through the lectures on this game haven’t finished yet, so, please if this movement is rectified in future lectures then tell me to crawl back under my rock and shut the hell up .
Anyway, we set up the movement: in the script via:
- this.rigidbody2D.velocity = new Vector2 (2f, -10f);
It’s good and gives a nice consistent movement for the ball, unless you hit it with the side of the paddle in which case it flies off every which way. Now in the original Arkanoid which I wistfully whiled away many an hour with the old Crummybore 64 - the movement as I recall was based on where if made contact with the “bat” as I will call it. I am going to change the graphic for the paddle to be longer and more like the “bat” in Arkanoid make it a little longer than the paddle.
Now, I would like to try and implement that type of movement, as it also makes it incredibly hard to put the game into a “boring” loop, move the bat a little and it changes the angle of movement. Now I don’t know enough about Unity and/or coding to go about it myself, so, I am hoping that some of you guys will be able to help me do this. And might need to include some more esoteric Unity stuff that I don’t know about. So, to do this, I’ll ask a series of questions to try and learn all the little steps that might make it possible. So I don’t want some person to write a complex series of coding with numerous scripts to make it work, I just want answer to the questions posed, and if it turns out that it’s a difficult task then I’ll deal with that when the time comes.
So, the game starts of and ball’s velocity is set in some random direction but usually with x direction being in the positive realm otherwise it just gets plain annoying. But after that the next contact determines the direction of the ball. If the contact is dead in the centre of the bat then ball moment is straight up providing you can get it dead centre, if contact is extreme right then it flies off to the right and same on the left and you have all those range of angles in between those two extremes.
So, the first question would be: is it possible to determine where the ball intersects the bat on the x and Y axis? And I suppose just as importantly can we do that through the OnCollisionEnter2d script? Or are we looking at something different here? And can we calculate the offset from the centre of the bat?
That’s all I can think of for now!
Vaughan.
EDIT: much thanks in Advance .