Goal: Rather than create and reprogram a new enemy actor for each new monster's appearance, to have the spawn point randomly generate different monsters and have the direction they're facing animate per monster, but using a single actor for the spawned enemy within the enemy spawner actor. So two actors created total: A spawn point, and the monster actor being spawned, which will have different animations for each new monster within the animation index.
The enemy will be able to follow the player with a moveTo event and will face left or right, depending on which side of the player the enemy clone is on.
I'm testing out variables, but they're not working as intended. Closest I get is two different monsters, but then the spawn point only produces the second monster over and over, and its animation flickers instead of going through the animation smoothly.
Here's what I tried:
"enemy" Actor/draw actor/script:
- Code: Select all
if (za==1) //variable for zombie A
{
if(x>player.x) // if enemy is to the right of player facing left towards player
{
ChangeAnimation ("Event Actor" , ZombieaL00001", NO_CHANGE);
//I tried animindex=0; here, but then that didn't animate correctly, and twitches.
}
if(x<player.x) // if enemy is to the LEFT of player facing Right towards player
{
ChangeAnimation ("Event Actor" , ZombieaR00001", NO_CHANGE);
//I tried animindex=1; here, but then that didn't animate correctly, and twitches.
}}
if (zb==1) //variable for zombie B (also animations within the same actor)
{
if(x>player.x) // if enemy is to the right of player facing left towards player
{
ChangeAnimation ("Event Actor" , ZombiebL00001", NO_CHANGE);
//I tried animindex=2; here, but then that didn't animate correctly, and twitches.
}
if(x<player.x) // if enemy is to the LEFT of player facing Right towards player
{
ChangeAnimation ("Event Actor" , ZombiebR00001", NO_CHANGE);
//I tried animindex=3; here, but then that didn't animate correctly, and twitches.
}}
//////
Spawn Point/timer/script editor: //this is after creating the timer 3 second loop.
- Code: Select all
type=rand(2);
switch(type)
{
case 0;
CreateActor ("enemy", "ZombieaR00001", "(none)", "(none)", 0, 0, false);
za=1; //zombie reference variable A
break;
case 1;
CreateActor ("enemy", "ZombiebR00001", "(none)", "(none)", 0, 0, false);
zb=1; //zombie variable B
break;
}
Variables declared under script editor/variables:
za is a integer global.
zb is an integer global too. I tried making them real actors, but that didn't work for some reason.
Just wonder what I might be missing to get the single enemy actor to display different animations and get the animations to play without twitching and not going through the animations.
I was going to put something in create actor, but that didn't work. Any help would be appreciated, thank you. I did a search but couldn't find this topic answered yet.
I'm wondering if maybe the spawn point actor's case 0 and case 1 are creating the actor and that actor's start animation are somehow interfering? I really wish we could createActor for clones. That would've saved a ton of time and challenging coding. So we'd be able to create "enemy.2", "enemy.4", whenever we wanted, but have each enemy clone have a different animation set.