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

Talk about making games.

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

Postby NevenResnik » Sun Jun 27, 2010 12:55 pm

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.
NevenResnik
 
Posts: 42
Joined: Mon May 31, 2010 9:59 am
Score: 0 Give a positive score

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

Postby Bee-Ant » Sun Jun 27, 2010 2:06 pm

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).
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

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

Postby NevenResnik » Sun Jun 27, 2010 2:58 pm

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!!
NevenResnik
 
Posts: 42
Joined: Mon May 31, 2010 9:59 am
Score: 0 Give a positive score

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

Postby Bee-Ant » Sun Jun 27, 2010 3:41 pm

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
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest