Page 1 of 1

How do I make an actor act as a homing missle?

PostPosted: Sun Jun 27, 2010 12:55 pm
by NevenResnik
Hey. I'm making a game. It's in serious development, and I'm stuck on an actor. I made a missle fired by an enemy toward the player, but it has to be a homing missle. Please help me make the missle move toward the player? Is it done by the Move To behaviour? If yes, with what activation event? Please help me. It's a crutial part of the game.

Thanks a lot in advance.

Re: How do I make an actor act as a homing missle?

PostPosted: Sun Jun 27, 2010 2:06 pm
by Bee-Ant
MoveTo() would make the missile ALWAYS chasing your target, and it would be bad...
Use this method instead...

1. MIssile->CreateActor->ScriptEditor:
Code: Select all
angle=direction(x,y,target.x,target.y);
directional_velocity=15;


2. Missile->CreateActor->CreateTimer (Choose new timer and fill these parameters) :
Name: AngleChange
Time (ms): 100
Type: Periodic
Min time: *
Repeat: Specify quantity
Count: 15

3. Missile->Timer->AngleChange->ScriptEditor:
Code: Select all
angle=direction(x,y,target.x,target.y);


With this method, your missile would chase after the target only in certain time (more real homing effect).

Re: How do I make an actor act as a homing missle?

PostPosted: Sun Jun 27, 2010 2:58 pm
by NevenResnik
Thanks a lot!!! I need a little more help. When I press the SPACE key I fire a bullet. Now I made a powerup. If you collect the powerup you start shooting the missle we made instead of the bullet when you press SPACE. Can that be achieved? I can't figure it out. Please take a second. Thanks a LOT!!

Re: How do I make an actor act as a homing missle?

PostPosted: Sun Jun 27, 2010 3:41 pm
by Bee-Ant
NevenResnik wrote:When I press the SPACE key I fire a bullet. Now I made a powerup. If you collect the powerup you start shooting the missle we made instead of the bullet when you press SPACE

OK, we need variables here...

1. First, make a variable. Go to Script Editor from any event. Click "Variables" button on the bottom window. Type "level" on the Name textbox, click Add.

2. Player->Keydown->Space->ScriptEditor:
Code: Select all
if(level<5)
{
    CreateActor("Bullet","YourBulletAnimation","(none)","(none)",0,0,false);
}
if(level>=5)
{
    CreateActor("Missile","YourMissileAnimation","(none)","(none)",0,0,false);
}
//in this case, we set the player can shoot missile if he got 5 powerups


3. Player->Collision->PowerUp->ScriptEditor:
Code: Select all
level++;


Note: always use ScriptEditor on any event, because we can easily edit them :D