PickRadius problem.
by Denis Linardic · in Torque Game Builder · 10/10/2005 (3:35 pm) · 3 replies
Hi!
I am trying to create somekind of blast radius explosion so when enemy is inside that radius to be destroyed.
I have tried with this code but there are few problems, please bare with me cos I am not very good in torque script (actually I am terrible as you can see) :)
After picking up upgrade , one explosion is created also in console there are few errors and
%wrapper.listObjects(); is 1832
echo(%picklist); is 1832 1912 1923......
So I am guessing that my code pass only first object into simset and ignore the rest...
I am ignoring the errors in console becouase I guess that %picklist.getCount wont work anyway.
Could you please give me a few pointers on how this could be handled.
I was also trying with pickPoint and specific layer but I think that pickRadius could be the best solution.
Anyway I am open to a sugesstions.
I am trying to create somekind of blast radius explosion so when enemy is inside that radius to be destroyed.
I have tried with this code but there are few problems, please bare with me cos I am not very good in torque script (actually I am terrible as you can see) :)
if ( %dstObj.upgradeType == 4 )
{
// Yes, so select all enemies!
%wrapper = new SimSet();
%pickList = spaceSceneGraph2D.pickRadius( $player.getPosition(), "100 100" );
for(%i = 0; %i < %picklist.getCount(); %i++) {
%wrapper.add(%picklist.getObject(%i));
spaceScrollerSceneWindow2D.startCameraShake( 5, 0.5 );
createExplosion( %wrapper );
safeDelete( %wrapper );
}
%wrapper.listObjects();
echo(%picklist);After picking up upgrade , one explosion is created also in console there are few errors and
%wrapper.listObjects(); is 1832
echo(%picklist); is 1832 1912 1923......
So I am guessing that my code pass only first object into simset and ignore the rest...
I am ignoring the errors in console becouase I guess that %picklist.getCount wont work anyway.
Could you please give me a few pointers on how this could be handled.
I was also trying with pickPoint and specific layer but I think that pickRadius could be the best solution.
Anyway I am open to a sugesstions.
About the author
#2
10/11/2005 (6:52 am)
Thanks, Ill try with that. I am sorry but my English is not very good and I am still learning Tscript.
#3
Minor problem is that explosion effect is deleted too quick, so it should be slowed down a little bit to leave time for effect to finish, but it's too late to play with that.
Thanks again guys!
10/12/2005 (2:50 pm)
Ok this is working with one minor problem so if anybody have similar problems feel free to use it. his is created by community anyway :) Thanks guys!// MEGA BOMB..
if ( %dstObj.upgradeType == 4 )
{
// Yes, so select all enemies in layer 3!
%enemiesList = spaceSceneGraph2D.pickRadius($player.getPosition(), "200 200", BIT(3));
%enemiesCount = getWordCount(%enemiesList);
for(%i = 0; %i < %enemiesCount; %i++)
{
getWord(%enemiesList, %i).safeDelete();
createExplosion ( %enemiesList );
}
// Player Upgrade#4 Audio.
alxPlay( upgrade1PickupAudio );//Curently using Upgrade#1
}Minor problem is that explosion effect is deleted too quick, so it should be slowed down a little bit to leave time for effect to finish, but it's too late to play with that.
Thanks again guys!
Torque Owner Hans Sjunnesson
Also, you should paste the errors in your console.log so we may see where the problem is.
Off-hand I'd say that you don't need to put everything in a SimSet and then delete that, just delete the current fxSeneObject2D from the picklist as you iterate through it. Also there's no such console function safeDelete (or maybe there is, I'm not a 100% sure). It's a member function of the fxSceneObject2D class. Also getObject() and getCount() works on SimSets, but the pick-methods returns vectors, which use getWordCount() and getWord(), so you'll want to change your iteration to something like:
for(%i = 0; %i < getWordCount(%picklist); %i++) { getWord(%picklist, %i).safeDelete(); spaceScrollerSceneWindow2D.startCameraShake( 5, 0.5 ); createExplosion( %wrapper ); }--
Hans