Making Spider Move from one end to another

Niraj Karki
Sep 26, 2021

2D Mobile Game

Objective: create a condition for spider to move from point A to point B.

First of all create an enemy script and inside the script, inherit from Enemy class and it will get access to all the variables and methods and make then unique to their own even if other enemies inherits and make use of them.

Inside the Spider script, create an override Update method since it has been declared as abstract method in Enemy class. Then inside the update function, check the enemy position where it checks if it is in either point A or point B and change the target to the other position. Then we used that target position to move the spider from the current location to that target position.

And this is the result.

--

--