Can not upload my game in sharemygame.com

I will upload game anyway then it will be easier for you to know the problems. There are a couple.

  1. Cursor wont move how it should with paddle.
  2. I added a pause menu but the animations i added plus ball and paddle wont pause. I think it’s something to do with the physics.

If you uploaded your game, tested it in your browser (icognito mode) and experienced bugs, please follow Rob’s instruction in this thread. Maybe there is a helpful error message in your browser console.

Regarding the issue with the paddle, make your life easy and use ScreenToWorldPos. Then you can drop the code for calculating the paddle position based on the screen width in World Units. In the example, cam and point are relevant for you.

awe thankyou so much for that info

i didnt have a problem downloading game today. i think it is probably security as i use 2 computers

Ive spent a few hours trying to use ScreenToWorldPos but with no change. Im probably doing it all wrong. Im quite new to coding and finding this really difficult.

Implementing ScreenToWorldPos is not that difficult, so I’m sure you are already on the right track. Maybe there is just a detail missing. You could share your code here. :slight_smile:


See also:

I trashed it sorry. Its confusing to me. There are no straight forward tutorials on how to do this anywhere

I accidentally called the method ScreenToWorldPos instead of ScreenToWorldPoint.

Here are a few steps:

  1. Assign the “Main Camera” to a variable. (See the example in the API or assign the reference as you learnt it in the course.)
  2. Call ScreenToWorldPoint. Pass the mouse position on to the method. (See the example in the API. You know how to get the mouse position because you already use it to move your paddle). Assign the returned value to a new variable, e.g. mousePos.
  3. Create a new Vector3 object with the current paddle position and assign it to a new variable, e.g. paddlePos.
  4. Assign the desired mouse coordinate in World Units, which you got from ScreenToWorldPoint, to the corresponding paddlePos component. (Hint: The Vector3 object consists of 3 components: x, y, z.)
  5. Assign the modified Vector3 object assigned to paddlePos to the transform.position of the paddle.

Done.

If you get stuck, please let me know and share what you have.

Alternatively, rewatch the videos. One of the objects probably has got a wrong position, or the aspect ratio is not set to 4:3 in the game window.


See also:

should it be 4:3 in the game window or 800x600 which appears smaller ? can you do 1920x1080 so you can have your own left and right border sprites rather than just a plane colour. Thanks for your help by the way :smiley:

If you prefer a different aspect ratio, feel free to design your game for that. However, Rick’s current solution requires you to do the maths to make the paddle follow the mouse.

For more flexibility try to implement ScreenToWorldPoint. Since you plan to make your game unique, it’s a good challenge. :slight_smile:

I would suggest to opt for a smaller resolution than 1920 x 1080 because not everybody on the internet has got a large screen. Mine, for example, has got a resolution of 1920 x 1200. In my browser, the upper and/or lower part of your game would be cropped.

ahh thanks for that info on resolution

When i press play the ball and paddle go to left side of screen. If i place mouse over the 2 objects and move mouse on the x axis to the right they only move when the mouse cursor is near to the right end of the screen . I just cant see any objects in wrong position my ratio is set to 4:3

Not sure if you already answered this question but is the camera position set to (8, 6, -10)? It is crucial that the left edge of the camera viewport box is at x = 0.

could it be to do with scaling and pixels per unit with the ball and paddle ? The sprite size of the ball is rather big so i scaled it down in the inspector.

yes that’s all correct

no difference at all i tested it with Ricks sprite which is smaller in size

Can you send a link to your game? I want to check it out. I want to see if the errors are on my end too.

game has been removed for now sorry

Also the ball and paddle are central bottom until i press play then they move to far left hand side of screen

Assuming your code is close to the code provided in the course and using 4:3 ratio etc I am guessing it might be something to do with the paddle script settings. So can you share screenshots of the inspector for the Gamecamera, and Paddle as shown below.

image

Privacy & Terms