Using non-player characters (NPCs)

Knowledgebase / Using non-player characters (NPCs)
NPCs
NPCs from the Gamefroot Classic Pack have a Classic Platform AI script attached to them. This makes them follow the player character around, damage the player when they collide, and even shoot bullets* at the player (if a bullet object is included in the game).
*Note: if a bullet object is not included in the game, then a warning message will appear at the start of the game.
To change its properties, right-click on it and select Instance Properties.
NPC-classic-AI
These are the properties you can change on an NPC:
  • Walking Enabled: Set it to true to make the character walk around, or set it to false to make them stand still.
  • Jump Enabled: Set it to true to make the character jump around, or set it to false to stop jumping.
  • Max Distance To Enemy: This is how close the NPC can get to the Player before it stops chasing.
  • Speed per second: The speed for the NPC.
  • Difference Before Jumping: The vertical distance between the NPC and the Player before the NPC starts jumping.
  • Jump velocity: The speed of the jump.
  • Sight Distance: How far the NPC can see. If the Player is outside this range, the NPC will not chase.
  • Damage on Touch: Sets the amount of damage that the NPC inflicts on the Player’s health.
  • Health: The amount of health the NPC has. If this reaches 0, the NPC will die.
  • Damage Player on Touch: Set it to true to make the NPC damage the Player when they collide.
  • Shooting Enabled: Set it to true to make the NPC shoot bullets at the Player. There must be a bullet in the level for this to work.
  • Movement time between Shots: The time the NPC spends moving around before it shoots again (times are in milliseconds, 1000ms = 1 second).
  • Stop time before/after shots: The time the NPC spends standing still after it shoots.
  • Gun Burst Shots: The amount of bullets that the NPC shoots at once.
  • Gun Muzzle Velocity: The speed of the bullets.
  • Gun Burst Bullet Delay: The time between each bullet in a single group of shooting.
  • Maintain Attack after sight lost: Set this to true to keep the NPC chasing after the Player temporarily.
  • Touch Hurt Delay: The time between the collision and the damage being inflicted.
  • Display Health Bar: Set this to true to display a health bar on the NPC (health bar object must be placed in level)
  • Score: The amount of points the player gets for destroying this NPC.