Data Realms Fan Forums http://45.55.195.193/ |
|
Request; Detection and velocities http://45.55.195.193/viewtopic.php?f=73&t=45288 |
Page 1 of 1 |
Author: | 4zK [ Wed May 15, 2013 8:29 pm ] |
Post subject: | 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. |
Author: | CaveCricket48 [ Fri May 17, 2013 10:06 pm ] |
Post subject: | 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? |
Author: | Foa [ Sat May 18, 2013 2:50 am ] |
Post subject: | 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. |
Author: | 4zK [ Sat May 18, 2013 6:40 pm ] |
Post subject: | 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. |
Author: | Shook [ Mon May 20, 2013 3:48 pm ] | ||
Post subject: | 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.
|
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |