enemy assitence #171
-
i was wandering how to code an enemy to attack the player when the player gets close |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The "Sol" enemy has a similar function, where it will fire the fireballs if it detects the player, specifically this line of code: // Check if the player is within range and not controlled x -= 0.25 * image_xscale; for (var i = 0; i < fireball_count; i++) I'd suggest using this badnik (and all other enemies included in Orbinaut) to help you make new ones. |
Beta Was this translation helpful? Give feedback.
-
thanks |
Beta Was this translation helpful? Give feedback.
The "Sol" enemy has a similar function, where it will fire the fireballs if it detects the player, specifically this line of code:
// Check if the player is within range and not controlled
if abs(_dist_x) < 160 && abs(_dist_y) < 80 && _player.state < PLAYER_STATE_NO_CONTROL
{
state = SOL_STATE_SHOOT;
}
}
x -= 0.25 * image_xscale;
angle = (angle - ANGLE_INCREMENT * image_xscale) % 360;
for (var i = 0; i < fireball_count; i++)
{
var _fireball = fireballs[i];
if _fireball == noone
{
continue;
}
I'd suggest using this badnik (and all other enemies included in Orbinaut) to help you make new ones.
Hope this helps.