View unanswered posts | View active topics It is currently Wed Dec 25, 2024 4:47 pm



Reply to topic  [ 5 posts ] 
 Request; Detection and velocities 
Author Message
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Request; Detection and velocities
I'm looking for a script that looks for targets (mainly actors) relative to where a shot particle is moving.

In this instance the particle is preferably a pixel, so I believe it's going to have to be sorted out through velocity.

Basically; a ~180° area in front of a pixel - as in relative to velocity, where it is moving to - preferably with an adjustable range of detection. Goal is to have the pixel change the course towards the found target, but only once.

It would also be nice if the particle would also detect either the outlines of the target or parts attached to the target, such as the engines on a drop ship, so that it wouldn't have to move as close to the center of the drop ship as it would have to with AHuman actors.


Wed May 15, 2013 8:29 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Request; Detection and velocities
I'm a bit confused as to what you mean by "relative to velocity." I'm guessing you want something like a 180 degree cone detection "field" in the direction that the particle is moving?


Fri May 17, 2013 10:06 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: Request; Detection and velocities
yep, I'm thinking of comparing the normalized velocity vector against the normalized vector difference of the position of the nearest actor, and the bullet's position... I'm not sure about how to wrangle a sure fire way though.


Sat May 18, 2013 2:50 am
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Re: Request; Detection and velocities
@CC; yes.

Since it's a MOPixel, there isn't really an 'angle' to it, so it can only be defined through velocity... right?

Though I'm sure that I could do one that has a full 360° field myself.

I'll still be looking forward to see if this can be done, though.


Sat May 18, 2013 6:40 pm
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Request; Detection and velocities
I'd recommend casting a fan of MORays for this, using a for loop. Something like this, except this is untested and might not work:
Code:
function Create(self)
   self.detecRange = degtorad(180);
   self.rayCount = 30;
   self.angleInc = self.detecRange/self.rayCount;
   self.range = Vector(500,0)
   self.target = nil;
   self.velChanged = 0;
end

function Update(self)
   local flightAngle = self.Vel.AbsRadAngle;
   if self.target == nil then
      for i=0, self.rayCount do
         local rayVector = self.range:RadRotate((flightAngle-(self.detecRange/2))+self.angleInc*i);
         local rayDurp = SceneMan:CastMORay(self.Pos, rayVector, self.RootID, -1, 0, false, 1);
         if rayDurp ~= nil then
            self.target = MovableMan:GetMOFromID(rayDurp);
            break;
         end
      end
   elseif self.velChanged == 0 then
      self.velChanged = 1;
      local angle = SceneMan:ShortestDistance(self.Pos, self.target.Pos, true).AbsRadAngle;
      self.Vel = self.Vel:AbsRotateTo(angle);
   end
end

In particular am i uncertain about AbsRadAngle, since the wiki says that it returns negative values when the angle is upwards, so to say. But hey, i tried, right? :U (also it's not perfect, the rays have large gaps between them)

Edit: Also note, this thing is set to ignore team -1, which may/may not be preferrable to change, depending on how much you love friendly fire.

Secondary edit: ALTERNATIVELY, determine a field of detection like this (self.Vel.AbsRadAngle +/- self.detecRange/2), and instead of using MORays which probably take a lot of CPU power, check the AbsRadAngle of the shortest distance between the bullet and the thing in question, and then check whether it's within the range or not, and whether the thing is close enough as well.


Attachments:
4zk lerp lorb.lua [826 Bytes]
Downloaded 356 times
Mon May 20, 2013 3:48 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.028s | 14 Queries | GZIP : Off ]