how do i make this constant /infinite Hope u help me as i know all of u r geniuses in prog

Updated on June 2, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on June 2, 2018

AmeenToday at 00:43

 
 
can Iget some help plz
 
 
 
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Moving_Enemy : MonoBehaviour { public int currentNode; public Transform[] path; public bool rotateTowardsCurve; void Update() { Move(8 *Time.deltaTime); } void Move(float dist_to_travel) { //check of the distance is 0 or less, that shouldnt do anything if (dist_to_travel <= 0) return; //please no index out of bounds if (currentNode == path.Length – 1) return; //distance from current point to the next node var nextNodeDist = Vector3.Distance(transform.position, path[currentNode + 1].position); //rotate if needed if (rotateTowardsCurve) { transform.rotation = Quaternion.LookRotation(Vector3.forward, (path[currentNode + 1].position – transform.position).normalized); } //if the distance we travel on this frame is equal or greater than the distance to the next node do this if (dist_to_travel >= nextNodeDist) { //increase node score currentNode++; //go to next node transform.position = path[currentNode].position ; //move with the remaining distance we can travel on this frame. Move(dist_to_travel – nextNodeDist); } else { //if not, just travel towards the next node we can go to. transform.position = Vector3.MoveTowards(transform.position, path[currentNode + 1].position, dist_to_travel); } } }
 
 
 
how do i make it constant
  • Liked by
Reply
0 on June 2, 2018

plz as I KNOW ALL OF UR PROGRAMMING GENIUSES.

  • Liked by
Reply
Cancel
0 on June 2, 2018

Could you please repaste your code with proper formatting.

 

  • Liked by
Reply
Cancel