About 'Distance As A Vector2'!

In this video (objectives)…

  1. Understand how to calculate the distance from ball to paddle.
  2. Update location of the ball to match the location of the paddle plus our offset.

After watching (learning outcomes)… Stick the ball to the paddle.

(Unique Video Reference: 10_BR_CUD)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

I’ve been having a really tough time with these videos. I want to learn this stuff, I really do, but the logic isn’t clicking for me. I can follow along and go step by step, but I will watch these videos at least 3 times over and I still will not be able to get the challenges. You talk about all of this stuff as if its blatantly obvious what to do, but it feels like you are speaking in a different language.

I try looking at the Unity Scripting API, but its all written in such a strange way. Is there another resource that goes more in depth into basic concepts and explains things a bit more simply?

2 Likes

Hi Sean,

Sincere respect for putting yourself out there with your post and saying that you are finding the learning journey challenging, a lot of people might not do that, some might just give up, it’s great to see that you are keen to keep progressing.

As with anything new, the learning journey can be challenging and will always be unique to the individual, with often no one solution being perfect for everyone. The Unity Scripting API is a good example of that. Some of the content in it is very straightforward and explained well, other areas less so, and some, well, you only get a brief description. Being able to consume resources such as that, or perhaps Microsoft’s own documentation for classes, methods and so on takes time, but stick at it, because you will find it gets easy the more you do it.

On that very note I would wholeheartedly recommend looking at the Unity Scripting API not only when something doesn’t click with you, but also when it does, this will give you more experience with their documentation and the way it is written and will help over time, and hopefully make the experience easier when you’re looking up something that hasn’t yet clicked.

With regards to other resources, well, there’s going to be a whole internet full of them, but sending someone to the place that is just right for them would be quite challenging, instead, what I would offer as advice would be to reach out whenever something isn’t clear. Whether you post your questions on the Udemy Q&A to get a response from one of the student instructors, or perhaps on the Discord channel, or here, you will invariably always get a response from someone willing to help you out, and if the response you have had isn’t clear enough for you, just ask them nicely to explain it in a little more detail - it’s a great community with lots of people willing to share and help each other.

I hope the above is of some use to you, and again, sincere respect for raising your hand and saying “hey, I’m not getting some of this”, that takes courage and the questions that you may ask in the future will also help lots of other people who have perhaps had a similar experience but have yet to muster the courage to ask for help. :slight_smile:

2 Likes

Hi, Rick,

In assigning a value for the first time to a new variable (other than a numeric type like float or int), we’ve previously always had to say “new,” as in “Vector2 paddlePos = new Vector2( . . . .” But I noticed we didn’t do that with paddleToBallVector. Is that because we assigned it using Vector2’s (“transform.position - paddle1.transform.position”)?

Thanks!
Ken

1 Like

Hi, Rick,

I thought of a second question. In the Ball script, we declared paddle1 as type Paddle. How does VisualStudio know that type? Is it because we declared a class Paddle in another script? Or does the name of the type need to correspond to the object we’ll bind to the variable in the Unity editor?

Both my questions today have to do with details I’m just curious about. I’m learning a lot, everything is working, and I’m enjoying watching the game come together and experimenting with my own little variations on what you’re doing.

Many thanks!
Ken

1 Like

Hi Ken,

About your 1st question,
Yes, you are right. As we are assigning it’s value using transform.position for the ball and the paddle which are vectors themselves, we don’t need to create a new Vector2 (which we would require if we were assigning vectors individually, like position.x or position.y).

About your 2nd question,
You are right again. Visual Studio knows the type Paddle because we have already created a class or template named Paddle. We are merely accessing that class through our Ball script and creating an instance variable for it called paddle1. This is how we are able to access the transform component of the paddle by saying paddle1.transform.position.
And no, the name of the type doesn’t correspond to the name of the game object we have in the hierarchy. It corresponds to the name of the script/class/template that is attached to that game object.
Hope this helps you out.

Good Luck!

2 Likes

Thanks for the good answers Yash!

2 Likes

Thanks, Yash! It’s fun to learn in a supportive community.

:slight_smile: Ken

2 Likes

Happy to help! :grin:

1 Like

Privacy & Terms