Data Realms Fan Forums http://45.55.195.193/ |
|
ACrabs and their silly antics http://45.55.195.193/viewtopic.php?f=1&t=25990 |
Page 1 of 1 |
Author: | Shook [ Wed Oct 26, 2011 9:56 pm ] |
Post subject: | ACrabs and their silly antics |
So yeah, been trying to make a turret that orients itself according to a nearby wall. While i miraculously managed to get the script fully functional, there's one little caveat. First, you place turrets on all four sides of a square. Then, the bottom one explodes. WHY? Is this some ridiculous hard-coded shenanigans by Data, and/or is there any way to bypass it? I guess i could just play around with the sprite and some Frame trickiness, but it'd be lovely if i (or anyone else) didn't have to, since it probably involves another few hours of intense raging. |
Author: | Gotcha! [ Wed Oct 26, 2011 9:59 pm ] |
Post subject: | Re: ACrabs and their silly antics |
Bizarre. Does it only happen when you place them like that? What if you put more space inbetween them? O_o |
Author: | Shook [ Wed Oct 26, 2011 10:11 pm ] |
Post subject: | Re: ACrabs and their silly antics |
Happens if you omit the three others entirely as well, so i doubt it's a case of interaction between the turrets. ¯\(°_o)/¯ |
Author: | Gotcha! [ Wed Oct 26, 2011 10:37 pm ] |
Post subject: | Re: ACrabs and their silly antics |
What the hell... Well, I guess 4 makes a crowd. >_> Maybe you can post your secret stuff here so great brainy minds can take a look at it? |
Author: | Azukki [ Wed Oct 26, 2011 10:44 pm ] |
Post subject: | Re: ACrabs and their silly antics |
I'm guessing hardcoded shenanigans. what the hell I've been skipping lines of text at random all day agh The frame thing really shouldn't be that hard at all. Just change self.Frame to 2 or whatever when you detect upward mounting, which you seem to already have taken care of. Also, you've probably have noticed this enough yourself already, but the mountings are sunk into the modules to varying degrees, and it'd look better if you avoided that. That is, assuming you have that module pictured on the grid and not moved slightly off it. |
Author: | Shook [ Thu Oct 27, 2011 12:21 pm ] | ||
Post subject: | Re: ACrabs and their silly antics | ||
Aye, that's true. I believe i have an idea to fix that, though. Also, count on me to forget the critical details. Here's the used Lua: Code: function Create(self) local checkRange = 50; for i=0, 3 do local angle = (math.pi/2)*i; self.endPos = Vector(0,0); local wallCheck = SceneMan:CastStrengthRay(self.Pos, Vector(checkRange,0):RadRotate(angle), 1, self.endPos, 0, 128, true); local dist = SceneMan:ShortestDistance(self.endPos, self.Pos, true).Magnitude; print(dist); if dist ~= nil then if self.oldDist == nil then self.closest = i; self.oldDist = dist; self.lastPos = self.endPos; else if self.oldDist > dist then self.closest = i; self.oldDist = dist; self.lastPos = self.endPos; end end end end print(self.closest); print(self.lastPos); if self.closest ~= nil and self.oldDist < 50 then self.RotAngle = (math.pi/2)*self.closest; self.Pos = self.lastPos + Vector(self.SpriteOffset.X,0):RadRotate(self.RotAngle); end self.PinStrength = 999; end function Update(self) if self.lastPos ~= nil and self.oldDist < 50 then self.RotAngle = (math.pi/2)*self.closest; self.Pos = self.lastPos + Vector(self.SpriteOffset.X,0):RadRotate(self.RotAngle); end self.HFlipped = false; end In a nutshell, it starts out by casting 4 rays in the cardinal directions, then finding out which one is closest. Then it uses that information to set an appropriate RotAngle, so that the base of the turret faces the wall, and then pins the everloving ♥♥♥♥ out of it. I realized another oddity though; the base faces right on the sprite ( O-| ), so technically the bottom one isn't upside-down, the rightmost one is. Maybe they don't like being turned more than 180 degrees? Don't know if that's the case at all, since i'm not sure which way the CC angles go (counter-clockwise in reality), but maybe they go clockwise since the Y-axis is inverted? Edit: This just in, CC angles go counter-clockwise. That means that it's the 90-degree turret that explodes. ¯\(°_o)/¯
|
Author: | jimbo8098 [ Thu Oct 27, 2011 2:40 pm ] |
Post subject: | Re: ACrabs and their silly antics |
does it happen if you just place the bottom one? |
Author: | Shook [ Thu Oct 27, 2011 3:25 pm ] |
Post subject: | Re: ACrabs and their silly antics |
Yup. In any case, i'm turning to the sprite-y approach now, but a definite conclusion to this would still be awesome. I mean really, it explodes when turned 90 degrees, but not 0, 180 or 270? Something's off here. Maybe it's trying to right itself up, but is prevented by the pinning, and thus accumulating enough impulse to explode it? |
Author: | Roast Veg [ Thu Oct 27, 2011 3:34 pm ] |
Post subject: | Re: ACrabs and their silly antics |
Try disabling the AI and see if that stops it from bugging out on you. |
Author: | Shook [ Thu Oct 27, 2011 5:26 pm ] |
Post subject: | Re: ACrabs and their silly antics |
How do? ¯\(°_o)/¯ The hard-coded AI doesn't seem to give a ♥♥♥♥ about me disabling it. Anyhoo, the spritey approach is working nicely, and was easier than i expected (aside from fixing a million offsets). No random explodage any more, now i just have to worry about the AI being extremely eager to flip it horizontally. Which would look dumb. This is more of a Lua question, but is it at all possible to prevent it from trying to flip? I know i can do HFlipped = false all the time, but it still flips both weapon and attachables. It would also be lovely if the player couldn't do that either, since it looks and feels silly. |
Author: | Roast Veg [ Thu Oct 27, 2011 5:36 pm ] |
Post subject: | Re: ACrabs and their silly antics |
Set the left/right control to be false all the time. Shook wrote: The hard-coded AI doesn't seem to give a ♥♥♥♥ about me disabling it. Can you not use the old self.AIMode = 0 on it? |
Author: | Shook [ Thu Oct 27, 2011 5:44 pm ] |
Post subject: | Re: ACrabs and their silly antics |
Nope, it's like a honey badger in that regard. I'll try that controller stuff though, hopefully it'll work. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |