Skip to content

Instantly share code, notes, and snippets.

@Henry-E
Last active August 29, 2015 14:22
Show Gist options
  • Save Henry-E/a81868cbe0d9d3052153 to your computer and use it in GitHub Desktop.
Save Henry-E/a81868cbe0d9d3052153 to your computer and use it in GitHub Desktop.
// this needs to go into the ship's AI script
public integer numFramesBetweenAICall;
integer currentFrame;
void Awake()
{
numFramesBetweenAICall = 5;
currentFrame = 0;
}
void Update()
{
currentFrame = mathf.repeat(currentFrame + 1, numFramesBetweenAICall);
if(currentFrame == 1)
{
// run AI logic
// for example
// closestAsteroid = GameManager.instance.ClosestAsteroid(transform);
// then do something with closestAsteroid
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment