Store information of distination to use in next script

Hello everybody,

The question is: how can I store the int information to be used farther in a script?

and here’s the line of code I use:

public int nextWayPoint;

 public void Patrol()
shopper.navMeshAgent.destination = SceneIndex.instance.waypoints[nextWayPoint].position;

[nextwayPoint] is an int.

I would like to make a transfrom varibale like “currentwayPoint”
and say currentwayPoint = nextwayPoint. like: SceneIndex.instance.waypoints[currentwayPoint].position
But I can’t because it has to be something associated with ints…


@Eco-Editor nextwayPoint is an Integer which cannot hold a reference to a Vector3. I would suggest you store the Transform as the next waypoint, like this:

Transform nextwayPoint = SceneIndex.instance.waypoints[currentwayPoint]

Then you can use it moving forward like this:


@fvde hi,
Im no expert but I think the whole idea of having “nextWayPoint” as an integer is because of the function that uses % sign for deciding what point is next.

            wayPoint = (nextWayPoint + 1) % points.Length;

How else would you reference the next wayPoint?