Ball Disappears After Using Ball Script

Hello!

First post here regarding the 2D Unity C# Lessons. I’m on Section 5 Lesson 55 and after running the Ball.cs Script it simply disappears off both screens and I just have no idea why. I’ve triple checked both the script for the ball and the paddle, and I just don’t understand what is going wrong. Btw Rick I am attempting to do this at 11:41 am, aha. Any help would be most appreciative.

Thanks!

Hi,

Welcome to our community! :slight_smile:

Is the z-position of the camera set to z = -10, the background to z = 10, and the rest to z = 0? If so, what position does the ball have in the Inspector when it disappears?

Hello! Thank you so much for the welcome and replying! :slight_smile:

So the main camera is set to z = -10, however could you clarify by what you mean by background? Are you referring to the canvas or the Blue Rocket Background? When the ball disappear the Inspector is showing that the x position is moving with the paddle I’m now noticing, however, the y becomes set at 0.25. I’ve provided screenshots for clarity

The “Blue Rocket Background” game object.

It might be that the ball gets rendered behind the blue background image due to the infamous z-fighting effect.

Oh I see! Is there a way to remedy that? Also is the Z position for the background supposed to be 10 then or are the above images correct to the lesson? I’ve tried tinkering with that along with shuffling the objects around with no success :frowning: Everything else remains except the ball object.

EDIT: Viewing the ball inspector again I’m seeing the ball’s Y drops to 0.25, I have no idea why this is happening as this doesn’t appear to happen in Rick’s lesson video. I’m more lost than ever! haha
BallHidden

There is a typo in line 14. The Unity method is called Start, not start. Maybe that was causing the issue?

Regarding the z-position, it might be that Rick set his background to z = 5. It doesn’t matter as long as the background is in front of the camera and behind the ball.

1 Like

Oh my gosh that was exactly the problem!! Nina, thank you so much - I can’t believe I didn’t see that discrepancy. Everything works fine now as far as I see. Thank you again!! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms