function Update(self) if self.Life:IsPastSimMS(5) then if SceneMan:FindAltitude(self.Pos, 500, 1) < 5 then self.penetrating = true end end self.ToSettle = false local Effect local Offset = self.Vel*(20*TimerMan.DeltaTimeSecs) -- the effect will be created the next frame so move it one frame backwards towards the barrel

for i = 1, self.dots do local checkPos = self.Pos + Vector(self.Vel.X,self.Vel.Y):SetMagnitude((i/self.dots)*self.raylength); if SceneMan.SceneWrapsX == true then if checkPos.X > SceneMan.SceneWidth then checkPos = Vector(checkPos.X - SceneMan.SceneWidth,checkPos.Y); elseif checkPos.X < 0 then checkPos = Vector(SceneMan.SceneWidth + checkPos.X,checkPos.Y); end end local terrCheck = SceneMan:GetTerrMatter(checkPos.X,checkPos.Y); if terrCheck == 9 or terrCheck == 10 or terrCheck == 11 then self:GibThis(); end end

end

as u maybe can see this is supposed to check if the round this .lua is attached to is close to something, aka going through it (high gib impulse limit, mass and strong deep material etc) and initiate a timer

my problem is, this is really, really unreliable

some rare times it fails to set off, and if i make the length requirement lower, it's even more sensitive, and sets off quicker (wut? shouldnt that mean it has to be even closer (wait more time) before setting off)

i've also tried to make it so that it only initiates the timer to gib itself once it's gotten OUT of the thing it touched - by making another length check, and only setting the timer off if the length is above a certain amount

this was met with tons of unreliability and i could make no sense of it

so what the heck is going on here?

EDIT: this is basically the gun right now

Last edited by Hoovytaurus on Sun Jan 22, 2017 10:30 am, edited 1 time in total.

Sat Jan 21, 2017 10:30 pm

CaveCricket48

Joined: Tue Jun 12, 2007 11:52 pmPosts: 10844Location: Here

Re: shoddy ray stuff

Well, to start with, SceneMan:GetTerrMatter only applies to terrain, not MOs. Another issue is that your projectile might be moving fast enough that it covers a larger distance per frame than the ray.

Sun Jan 22, 2017 12:44 am

Hoovytaurus

Joined: Mon Dec 21, 2015 9:30 amPosts: 82

Re: shoddy ray stuff

CaveCricket48 wrote:

Well, to start with, SceneMan:GetTerrMatter only applies to terrain, not MOs. Another issue is that your projectile might be moving fast enough that it covers a larger distance per frame than the ray.

the terrmatter stuff is just to check for dirt - i want it to penetrate concrete and other things but not act like a gunpowder-powered digger. surprisingly, that part works flawlessly. the part above, with the obstacle ray, is the one that is unreliable

should i increase ray length, then? its shot out with a velocity of 170, which is pretty fast i suppose but i dont think it moves 25 pixels a frame, does it?

Sun Jan 22, 2017 10:16 am

CaveCricket48

Joined: Tue Jun 12, 2007 11:52 pmPosts: 10844Location: Here

Re: shoddy ray stuff

Took a closer look - looks like while the obstacle ray is 25 pixels long, you're only checking if the projectile is within 5 pixels of an obstacle, so your ray is effectively only 5 pixels.

If you want to have a longer, more reliable ray/distance check while still having the projectile detonate up close, you could try teleporting the projectile closer before detonation.

Sun Jan 22, 2017 4:53 pm

Hoovytaurus

Joined: Mon Dec 21, 2015 9:30 amPosts: 82

Re: shoddy ray stuff

CaveCricket48 wrote:

Took a closer look - looks like while the obstacle ray is 25 pixels long, you're only checking if the projectile is within 5 pixels of an obstacle, so your ray is effectively only 5 pixels.

If you want to have a longer, more reliable ray/distance check while still having the projectile detonate up close, you could try teleporting the projectile closer before detonation.

well the point of this script is to initiate a boom-timer upon it penetrating sometimes

for example, if there is a guy hiding in a bunker, i can fire through the wall and have the round explode just after penetrating, rather than on the surface, or not at all and just plowing through the guy instead

im not sure what teleporting it would achieve here

to elaborate, the problem is that sometimes it seems to detonate instantly upon it touching a wall, sometimes it works well, and sometimes it completely fails to detonate, even when in circumstances where it should (ive seen it get stuck in a very thick concrete wall and just sit there, encased in concrete without exploding - and the timer is shorter than the time it took to settle!)

maybe i could use the second bit of the code to achieve it since it's rather reliable, but then i'd have to manually add in every material i want it to act that way to

Sun Jan 22, 2017 5:22 pm

CaveCricket48

Joined: Tue Jun 12, 2007 11:52 pmPosts: 10844Location: Here

Re: shoddy ray stuff

Okay so, this script is supposed to detect an obstacle (MO or terrain), and then start a timer. Then, when the timer finishes, it explodes.

Is it possible infinitely restarting the timer, for the scenario where it's embedded in walls and not doing anything?

Sun Jan 22, 2017 5:49 pm

Hoovytaurus

Joined: Mon Dec 21, 2015 9:30 amPosts: 82

Re: shoddy ray stuff

CaveCricket48 wrote:

Okay so, this script is supposed to detect an obstacle (MO or terrain), and then start a timer. Then, when the timer finishes, it explodes.

Is it possible infinitely restarting the timer, for the scenario where it's embedded in walls and not doing anything?

i was gonna write no then i took a look at the code, yeah that might be possible

would putting a length less than 5 AND self.penetrating == false check work to fix that? then it can only reset once

firing at a direct, downwards into the ground, seems to produce most duds

firing at a pretty horizontal angle towards the ground makes it prematurely detonate, penetrating even less than expected even if you factor in the fact that it has to go through more ground thanks to the angle

firing through very thin walls or corners fails to set off the timer and will produce a dud, until it plows into something else

Sun Jan 22, 2017 6:19 pm

CaveCricket48

Joined: Tue Jun 12, 2007 11:52 pmPosts: 10844Location: Here

Re: shoddy ray stuff

Out of curiosity, what are the dimensions of the sprite of the projectile?

I'm wondering if the premature detonation (when firing at a mostly horizontal angle into the ground) is due to the terrain check? Are you testing on dirt ground or concrete/scrap ground?

Producing a dud through corners and very thin walls is probably due to the 5 pixel length check - if the projectile is traveling faster than 5 pixels per frame, it would effectively have "holes" in its detection, and be able to miss thin walls.

Firing directly into the ground and getting duds- if this is before adding the self.penetrating check to "if length <= 5 then", it sounds like it's infinitely resetting the timer.- if this is after adding the self.penetrating check, then that's strange, and would ask what you have set for the projectile's RestThreshold.

Sun Jan 22, 2017 7:33 pm

Hoovytaurus

Joined: Mon Dec 21, 2015 9:30 amPosts: 82

Re: shoddy ray stuff

CaveCricket48 wrote:

Out of curiosity, what are the dimensions of the sprite of the projectile?

I'm wondering if the premature detonation (when firing at a mostly horizontal angle into the ground) is due to the terrain check? Are you testing on dirt ground or concrete/scrap ground?

Producing a dud through corners and very thin walls is probably due to the 5 pixel length check - if the projectile is traveling faster than 5 pixels per frame, it would effectively have "holes" in its detection, and be able to miss thin walls.

Firing directly into the ground and getting duds- if this is before adding the self.penetrating check to "if length <= 5 then", it sounds like it's infinitely resetting the timer.- if this is after adding the self.penetrating check, then that's strange, and would ask what you have set for the projectile's RestThreshold.

i am testing it on concrete ground, firing it into dirt produces instant detonation - as expected and properly working, no worries there

so the only way to fix that is to make the length - or lack or it - bigger? perhaps if i also increase the timer this could make it more reliable without necessarily messing up the intended timing

the dimensions of the round itself are 23 long and 5 thick

there is no restthreshold defined - at the time of making this i knew there was something like that but failed to remember. what should i set it to?

Sun Jan 22, 2017 7:43 pm

CaveCricket48

Joined: Tue Jun 12, 2007 11:52 pmPosts: 10844Location: Here

Re: shoddy ray stuff

Set your RestThreshold to a negative number, this will keep it from settling. -500 or something. After that, mess around with your timer delay and ray check length, see if you can get something workable. With the self.penetrating check before resetting the timer, it shouldn't produce duds (outside of not properly detecting small terrain).

Sun Jan 22, 2017 7:55 pm

Hoovytaurus

Joined: Mon Dec 21, 2015 9:30 amPosts: 82

Re: shoddy ray stuff

CaveCricket48 wrote:

Set your RestThreshold to a negative number, this will keep it from settling. -500 or something. After that, mess around with your timer delay and ray check length, see if you can get something workable. With the self.penetrating check before resetting the timer, it shouldn't produce duds (outside of not properly detecting small terrain).

i will try just that and report back in an edit

does 20 if-requirement on the length stuff sound good? how fast is "170" anyway?

EDIT: ok this is very interesting

i have tested and i commented out the self.epentrating == true from the altitude check

it stopped working completely, as if the obstacle ray was doing nothing at all

i set length to less than 40, which should be foolproof, but it still seems to straight up not work

function Update(self) if self.Life:IsPastSimMS(5) then if SceneMan:FindAltitude(self.Pos, 500, 1) < 5 then self.penetrating = true end end self.ToSettle = false local Effect local Offset = self.Vel*(20*TimerMan.DeltaTimeSecs) -- the effect will be created the next frame so move it one frame backwards towards the barrel

Who is online

Users browsing this forum: No registered users

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