Author Topic: Rotating a Missile.  (Read 1669 times)

So I edited Aloshi's guided missile to spawn high up in the air with the intention of making a Predator Missile type thing. However at the moment the missile spawns parallel to the ground like so:  >>-->. What I'm wanting to make it do is make it point directly at the ground upon spawning like so: V
                                                                                                       l
                                                                                                       V.

Code: [Select]
%rot = "0, 0, 90, 0";
From this section of code.

Code: [Select]
{
//cooldown cheatery prevention
if(%obj.lastGuidedRocketFireTime != 0 && getSimTime() - %obj.lastGuidedRocketFireTime < 5000) //5s
return;

%obj.lastGuidedRocketFireTime = getSimTime();

%pos = %obj.getTransform();
%forvec = %obj.getForwardVector();
%pos = VectorAdd(%pos, vectorScale(%forvec, 2));

%allrot = %obj.getTransform();
%rot = "0, 0, 90, 0";
%pos = vectorAdd(%pos, 0 SPC 0 SPC 250);

%bot = new AIPlayer()
{
datablock="MissileBot";
};
clearAllPlayerNodes(%bot); //Makes the bot invisible
%bot.mountImage(missileimage, 2); //Mounts a missile so it looks like its a missile
%obj.client.setControlObject(%bot); //Control the missile
%bot.setTransform(%pos SPC %rot); //Reset the rotation

%bot.owner = %obj.client; //Set owner to you
%obj.client.bot = %bot; //Set your bot to the bot
pushBotToPos(%bot); //Start the missile-pushing
}

(Yes I am terrible at scripting.)

Code: [Select]
rotation = eulerToMatrix("0 0 0");X Y Z so tip down would be:
Code: [Select]
rotation = eulerToMatrix("0 90 0");
Edit: Checked Appendix A. It appears you can't rotate projectiles in the script. The method I posted is for items.
« Last Edit: January 04, 2012, 11:12:33 AM by Demian »

Edit: Checked Appendix A. It appears you can't rotate projectiles in the script. The method I posted is for items.

This is not an item, nor projectile. This is a invisible bot with an image mounted to it.

Edit the playertype, also, mess around with THIS portion of the script.
Code: [Select]
function guidedrocketLauncherImage::onFire(%this, %obj, %slot)
{
//cooldown cheatery prevention
if(%obj.lastGuidedRocketFireTime != 0 && getSimTime() - %obj.lastGuidedRocketFireTime < 5000) //5s
return;

%obj.lastGuidedRocketFireTime = getSimTime();

%pos = %obj.getTransform();
%forvec = %obj.getForwardVector();
%pos = VectorAdd(%pos, vectorScale(%forvec, 2));

%allrot = %obj.getTransform();
%rot = getWords(%obj.getTransform(), 3, 6);

%bot = new AIPlayer()
{
datablock="MissileBot";
};
clearAllPlayerNodes(%bot); //Makes the bot invisible
%bot.mountImage(missileimage, 2); //Mounts a missile so it looks like its a missile
%obj.client.setControlObject(%bot); //Control the missile
%bot.setTransform(%pos SPC %rot); //Reset the rotation

%bot.owner = %obj.client; //Set owner to you
%obj.client.bot = %bot; //Set your bot to the bot
pushBotToPos(%bot); //Start the missile-pushing
}

function pushbottopos(%bot)
{
if (!isObject(%bot))
return;

if(isEventPending(%bot.pbtoTick))
cancel(%bot.pbtoTick);

//If the owner dies while flying the missile
if(!isObject(%bot.owner.player))
{
MissileExplode(%bot.getPosition(), %bot.owner);
%bot.schedule(100, delete);
%bot.owner.setcontrolobject(%bot.owner.player); //Switches control to you again
return;
}

%ppos = %bot.getEyeVector();
%vec = %ppos;
%vec = VectorNormalize(%vec);
%vec = VectorScale(%vec, 45);
%bot.setVelocity(%vec);
%bot.pbtoTick = schedule(100, 0, "pushbottopos", %bot);
}

Code: [Select]
rotation = eulerToMatrix("0 0 0");X Y Z so tip down would be:
Code: [Select]
rotation = eulerToMatrix("0 90 0");
Edit: Checked Appendix A. It appears you can't rotate projectiles in the script. The method I posted is for items.
Even though this is now irrelevant, it would work fine in his case because he only wants it like that when it spawns.

This is not going to work because it's a bot. You can only rotate a bot on the Z axis.