Hook X Movement

The Fish Master The Fish Master
12 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.99
List Price:  €92.84
You save:  €27.85
£55.80
List Price:  £79.72
You save:  £23.91
CA$95.74
List Price:  CA$136.78
You save:  CA$41.04
A$105.97
List Price:  A$151.39
You save:  A$45.42
S$94.71
List Price:  S$135.31
You save:  S$40.59
HK$547.38
List Price:  HK$782
You save:  HK$234.62
CHF 63.50
List Price:  CHF 90.72
You save:  CHF 27.21
NOK kr760.18
List Price:  NOK kr1,086.02
You save:  NOK kr325.83
DKK kr484.74
List Price:  DKK kr692.51
You save:  DKK kr207.77
NZ$116.49
List Price:  NZ$166.43
You save:  NZ$49.93
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,679.15
List Price:  ৳10,970.69
You save:  ৳3,291.53
₹5,844.24
List Price:  ₹8,349.28
You save:  ₹2,505.03
RM331.61
List Price:  RM473.75
You save:  RM142.14
₦86,437.65
List Price:  ₦123,487.65
You save:  ₦37,050
₨19,466.20
List Price:  ₨27,810.05
You save:  ₨8,343.85
฿2,579.91
List Price:  ฿3,685.75
You save:  ฿1,105.83
₺2,258.19
List Price:  ₺3,226.13
You save:  ₺967.93
B$355.28
List Price:  B$507.56
You save:  B$152.28
R1,291.06
List Price:  R1,844.45
You save:  R553.39
Лв127.20
List Price:  Лв181.73
You save:  Лв54.52
₩95,163.27
List Price:  ₩135,953.36
You save:  ₩40,790.08
₪260.34
List Price:  ₪371.93
You save:  ₪111.59
₱4,006.12
List Price:  ₱5,723.27
You save:  ₱1,717.15
¥10,811.89
List Price:  ¥15,446.23
You save:  ¥4,634.33
MX$1,180.56
List Price:  MX$1,686.59
You save:  MX$506.03
QR255.22
List Price:  QR364.61
You save:  QR109.39
P950.05
List Price:  P1,357.27
You save:  P407.22
KSh9,308.67
List Price:  KSh13,298.67
You save:  KSh3,990
E£3,339.92
List Price:  E£4,771.52
You save:  E£1,431.60
ብር4,017.22
List Price:  ብር5,739.13
You save:  ብር1,721.91
Kz58,559.69
List Price:  Kz83,660.29
You save:  Kz25,100.60
CLP$65,083
List Price:  CLP$92,979.70
You save:  CLP$27,896.70
CN¥496.09
List Price:  CN¥708.73
You save:  CN¥212.64
RD$4,059.13
List Price:  RD$5,799
You save:  RD$1,739.87
DA9,404.13
List Price:  DA13,435.05
You save:  DA4,030.92
FJ$157.14
List Price:  FJ$224.49
You save:  FJ$67.35
Q543.86
List Price:  Q776.98
You save:  Q233.11
GY$14,638.84
List Price:  GY$20,913.53
You save:  GY$6,274.68
ISK kr9,768.50
List Price:  ISK kr13,955.60
You save:  ISK kr4,187.10
DH701.39
List Price:  DH1,002.03
You save:  DH300.64
L1,239.86
List Price:  L1,771.31
You save:  L531.44
ден4,006.46
List Price:  ден5,723.76
You save:  ден1,717.29
MOP$563.24
List Price:  MOP$804.66
You save:  MOP$241.42
N$1,288.69
List Price:  N$1,841.06
You save:  N$552.37
C$2,575.52
List Price:  C$3,679.48
You save:  C$1,103.95
रु9,351.66
List Price:  रु13,360.08
You save:  रु4,008.42
S/260.79
List Price:  S/372.58
You save:  S/111.78
K270.67
List Price:  K386.69
You save:  K116.01
SAR262.50
List Price:  SAR375.01
You save:  SAR112.51
ZK1,901.47
List Price:  ZK2,716.50
You save:  ZK815.03
L323.43
List Price:  L462.07
You save:  L138.63
Kč1,625.98
List Price:  Kč2,322.93
You save:  Kč696.95
Ft25,280.20
List Price:  Ft36,116.11
You save:  Ft10,835.91
SEK kr759.20
List Price:  SEK kr1,084.61
You save:  SEK kr325.41
ARS$61,608.98
List Price:  ARS$88,016.60
You save:  ARS$26,407.62
Bs483.53
List Price:  Bs690.78
You save:  Bs207.25
COP$273,394.26
List Price:  COP$390,579.97
You save:  COP$117,185.71
₡35,797.53
List Price:  ₡51,141.53
You save:  ₡15,343.99
L1,728.55
List Price:  L2,469.47
You save:  L740.91
₲523,227.64
List Price:  ₲747,500.10
You save:  ₲224,272.45
$U2,673.53
List Price:  $U3,819.50
You save:  $U1,145.96
zł280.44
List Price:  zł400.65
You save:  zł120.20
Already have an account? Log In

Transcript

What's up guys? Omar here from magic Tony. And we are continuing our the fish master game. Before I go to creating scripts and scripting, I want to mention that adding this background here is just for now so that fishermen one can be deleted. I mean, you can delete them right now without going to leave it because I like you there and back to can be also deleted because it will not be used. Because we have our back three here or can use here going back to it looks nicer, we can test this out.

But as I said, for the fisherman, we're going to add it another way, but you can even keep it like this. So I mean, it depends on you more likely, but I'm going to show you what the other way is when it comes time to it and why it's kind of better. So don't mind that. Just continue adding our folder inside of the projects of grant click go to create Create a folder and create our Scripts folder like this. Inside the Scripts folder, we are going to have our another folder or subfolder which going to be for the hook so hook like this. I mean this game isn't that big, but I just had an I can't over stress this much.

I like to keep things organized and I love to keep things organized and it makes it makes a project a lot more seeable so right now if I were searching scripts, I know exactly what search in Scripts folder. If I were searching for the hook script, I know where to find it. If let's say I add some managers here I will go to manager scripts and so on. I mean for this point, you can even say like as a whole line I mean here z like this, you can have like five more scripts, but still imagine having like one towel In scripts, and you have to find one single one, I mean one single one What, what the heck, one single script and you do not know name so you can search it like this. So you can access like this because you're not sure how is it called or something like that.

It will be a troublesome, it will be troublesome and won't give that I can give you when you start your game, you can always go here and click on the script and it will go immediately there. So as I was saying, inside or inside of the hook, we're going to have a C sharp script, which is going to be called hook. Imagine that not new behavior script, but actually C sharp script is called hook. I'm going to delete this because it's not needed. Once that is done, add our hook script to our hook so I can show you the example. So if I were searching for the hook, I can click here or double click it to open up, and to go right where it is.

You see, we open up our script as we want as we wanted. And we write right where our script is inside of the Unity but it is not I will show you since he took it, he'll go immediately to the color wait is. So first of all, I always start things by deleting the comments. So do that. And first we are going to add our public friends form. Then we're going to add our hook, friends, trend, transport, misspell it.

Yep. Then we're going to have our private camera, which is going to be our main camera like this. Then we're going to have our private integer which is going to be Are lent them pirate in strength, the strength this not strength sprang legs when g h. Like this, they will have our private ID fish count like this which cancel how many pieces we have. We have then we are going to have our private collider 2d that we're going to need call for strike shortcut. Then we're gonna have our private private bool which is going to be called can move. So we can know when can we move so I'm going to change this to here so it looks a bit more organized.

Yeah, then we will have our script I mean our list of patients So fish, but we have to have our fish script. So we're going to add that later on. And last but not least, we're going to have our winner and that is what I was mentioning before when we have added our assets for the how's it called for the animations so to use a tweener you will go up adding using Unity engine or not using the G dot tween. So this so using the G document and now we can access our private Twitter. We just called camera we like this simple. Now inside of the start function, we're going to change it to awake because awake starts first.

And I'm going to show you example right now what do I mean by that? Start like this. Start. If I need Brent here, bring this This message will be first and then I had here in the start another message which will be second like this, let me close it and add quotes. If I would go if I were to go to console right now, and let me just wait put into loaded up pull it up here and when I start, you will see that the first comment will be this message will be first and that is our message which is method which is called in awake. What do I mean by that?

Well basically, when script starts, both of these are using for instance, initially initially, let me try to pronounce this correctly. Initially, initial ization. I cannot do it but you know what I need in his shell is for any instantiate that says That means grading but in nice in it Okay, you know what I mean? It's nothing I will probably come around the video so you can know what exactly what I mean. And when it comes to that away comes first so it goes away and start. So by having that in mind I usually put kind of like getcomponent this or that in the awake function.

So inside of the awake function we're gonna say Are we gonna say main camera equals to camera dot main like this. There we're gonna have our collider which equal to get component in we're getting our collider to the quality and here we are gonna have for our fishes when it comes to our list so I'm going to say get a list fish like this. So we can know what we did not do and what we have to do later on. So first for our hook, I'm going to make it go left or right so I'm going to stay here if we can move and not deal with and so these two are called and when you put this together it's end and when you put sweet bars or mines, this is all and I explained the difference between in C sharp so exactly know what I mean.

So and input so input dot get axis or get it but input dot get mouse button, mouse button and we are getting our left click because it's zero. If you put one it's right click zero it will have slick. So if that is true, we are going to say vector three vector three vector called vectoring equals two main camera dot screen. To world point, and then we are pointing at input dot mouse position like this. This is where are we headed, and that we're going to have our vector three. So come on, come on, come on, come on vector three, come over to pre position, a position like this, equals you transform that position like this.

Start position equals to transform that position, interest in that position is position of our hook. Now position x to position x, I mean dot x equals two vector three dot x. What's this? Well, basically, we are having our press from that position, which is position for our hook, saying that it equals to where the X of our mouse is. So if I click here, if I click live here, the hook will move there. If I click here to the left hook will go There, and so on, so forth.

So let me go to zero. That should by fact, click here, hook will go to the left side, if I click here, it will track to the right side. Now you know what I mean. And you'll, you'll see that later on. And last but not least, we're going to say transform dot position equals to position like this. So it actually changes it with this.

First we're gonna say can move equals to true, so we can actually test this out because it has to be true. And if you don't put it to be true, by default, it's False. False. So right now, if I were to put the hook bit more and then zero for now or not with five, let's start our game. Come on, if I see if I, if I if I'm just moving that happens, but if I click there, and I can drag it with it. So this is the When it I was trying so we can move it left or right.

That is what we are trying to accomplish and we accomplished it. Yeah. So that will be it for this video about the hook. Anything I just want to say is if I do right now the hook, I mean I can I click then it hooks, but it will take too much time and this video will be kept to one, but I'm going to give you give you give you here a break. So you can actually rest a bit and then go to another review which right next up if you like it, and then of course continue with the hook. But before we do that, I'm going to put a hook hook hook transplant to our hook transfer here.

And with that we are done with this video. So what did we accomplish here we accomplish that we can move our hook left or right depending where do we Click on the screen it's pretty cool all right pretty cool that will be it guys are now you guys guys guys guys in the next video

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.