SO I DO NOT KNOW WHAT HAPPENS HERE! PEOPLE DISSAPEAR! LIKE A PERSON WITH 8 MIN READ TIME VISITED 3 DAYS AND NEVER SHOWED HIS FACE AGAIN ON THE FORUM! my point is, why do people give up so easily, like i was doing this unity course by Pablo Farias Navarro, it’s awesome, but there is one guy there, who’s like near giving up, so i explained everything to him, like this:
Firstly, whatever happens, never give up, I basically had the exact same problem as you but i got over it, so even if you don’t understand just keep going or ask on the forum, people are always there to help, never get discouraged, Vectors are like coordinate points, Vector3 is a point in 3d space, and Vector2 is a pint in 2D space used in 2D games, pablo explains what time.detatime is, it’s just makes the game feel less choppy even if you have a slow computer, it just calculates the time taken in between frames and gives an output to make your overall movement smoother, its like if you have a fast computer you character should not move fast and if you have a slow computer your character should not move slow, it should move at the same speed for both computers.
the float movementY represents the Y axis movement in left handed coordinates, factor is idk what it is, been a long time since i saw this code, speed is a number which specifies how fast your enemy is gonna move, time.deltatime is for equal movement over all devices as i eexplained before, and direction is to change the direction of the enemy movement, when you change direction to -1 everything in movementY becomes negative, so your enemy goes down, and when direction is 1, everything is in movementY is positive and your enemy goes up, so now movementY is a value for movement which determines all the values explained above.
transform is, well the transform of the object, which includes scale, rotation, and most importantly position, you can determine which axis you want to add to by adding a .(yourAxis) like this, so in this case you are modifying the vertical(Y) Yaxis of your enemies, so here it is transform.position.y (whatever you add to this modifies the y transform), so now you are modifying the yAxis of your enemy by adding movement Y to newY , so now you have modified the position of your enemies in the Yaxis using your movement value.
matf.Abs(value to convert to absolute value here) is a method to convert the value which you put in the brackets to its absolute value, eg. if you put -1 in there it will return a absolute value of 1.
initialPosY is the original position if your enemy.
so here you are checking if your newY – initialPos.y to absolute value is greter than the rangeY, rangeY is how far you want your enemy to travel and come back, so if your enemy has left your range, your changing the enemy’s direction by changing your direction to -1, so now your enemy is travelling the opposite direction.
ok, here is where it gets a little complicated, so transform.position is the position of your enemy in 3d space(in all the x,y and z axes) unlike before when it was only 1 axis eg, the y axis of your transform is transform.position.y, so now as i explained what a vector3 is, you are modifying the transform by adding your vector3 to it,
a vector3 is like this vector3(xAxis here, yAxis here, zAxis here), so since we have to move our enemy in the yAxis, we put our movementY in the Vector3 yAxis are like this: new Vector3(0, movementY, 0);
so now you are adding the Vector3 which determines your vertical movement to your transform.position and now your enemy’s position changes.
hope this makes sense and helps, remember never get discouraged, and if you have more questions, me and Pablo an others are there to help, and also there are tons of people on the Unity3d forum, so don’t hesitate to ask, Thanks!
hope he understands not to give up and ask
everybody who has problems right now, don’t hesitate to ask and never give up, your are going to get tons of problems with your printer, but you should never give up! conclusion never dissapear from the forum if you have a Flux.
and also, where is @BoozeKashi haven’t seen your profile pic in a long time!