This week we started working on the enemy waypoints , we would push empty game objects and place them onto the stack and pop them as the enemy reached a certain checkpoint .Though it may sound simple it is actually , i don't mean to cause any unnecessary nervousness but it is not as easy as it sounds . Before we start you should add the namespace " using System.Collections.Generic ; " .
This name space gives access to interfaces and classes that define generic collections .
Making the other function , it will be called transforming Position .To start of make an if to check that waypoints are not equal to 0 then do something .Within the if get the next point to move towards using vector3 targetPoint = wayPoints.peek , this will get the position to move towards .
We will declare a float called step in the function , which will multiply a newly declared speed float variable by time.deltatime , name this transformSpeed .Next we will make a vector3 called nextPos which will equal to vector3.movetowards () ; in the move towards specify current transform.position , targetPoint . speed variable . Now we have the code to transform the position of the enemy over time , i would recommend to make speed float public and specify the speed of 2.0f and increase it in small increments or decrements to get a desired speed .
Next make an if condition to check if the transform.position == target point then you can pop from the waypoints stack . After the if , next we will need to jump into vector3 nextPos , this can be done by saying transform.position = nextPos .
This is what your code will look like , in order to make mine slightly cleaner i have created two functions .The first function is called in start and the second in update .
My goal for the next week is to start working on the health
bar and maybe the torrent I would need to shoot the projectiles .
Dotnetperls. (n.d.). C# Stack Collection. Retrieved November 29, 2015, from http://www.dotnetperls.com/stack

No comments:
Post a Comment