Author Topic: Vector Help  (Read 907 times)

vectors are loving hard

Code: [Select]
function Player::forget(%this)
{
%start = %this.getEyePoint();
%vec = %this.getEyeVector();
%end = VectorAdd(%start, VectorScale(%vec, 60));

%ray = containerRayCast(%start, %end, $Typemasks::PlayerObjectType | $Typemasks::FXbrickObjectType | $Typemasks::TerrainObjectType | $Typemasks::InteriorObjectType | $TypeMasks::VehicleObjectType, %this);
%huh = getWords(%ray,1,3);
%ee = VectorAdd(%start,%huh);

for(%i=0;%i<10;%i++)
{
%gay = VectorSub(%end,vectorScale(%ee,%i/10));
spawnEmitter(SWDroidBlasterEmitter,%gay);
announce(%ee);
}
}

I'm trying to spawn a beam of particles along a vector, but I can never get the vector right. is there a good method that I can use to place a particle every 1 TU along a vector until the vector ends or gets a containerRaycast object

psuedocode/actual example would be helpful since i'm a dumbass when it comes to TS

You only get %ray correct if it actually hits something from the masks you have

Wouldn't something like this work?
Code: [Select]
%start = %this.getEyePoint();
%vec = %this.getEyeVector();

for(%i = 0; %i < 60; %i++)
{
      %pos = vectorAdd(%start, vectorScale(%vec, %i));
      spawnEmitter(SWDroidBlasterEmitter, %pos);
}
I'm mostly just guessing.

EDIT: You'd also have to fire a raycast and make the line not go as far if it hits something.

That would work I believe, though if you'd like the emitter to go all the way to the object you're looking at, you'll have to fire a really long raycast first then get the position of where the raycast hits ( there's a function for this, unsure what it is currently ) and then just have the for loop length be the distance between the start and hit position.