How to flip placed TDExplosives by placement direction?
Author
Message
BlueComet24
Joined: Sun Mar 08, 2015 11:57 pm Posts: 8
How to flip placed TDExplosives by placement direction?
I made Claymores that are basically like Remote Explosives but with a directional blast. They work great except that when I place them, they always face to the right. I want them to be so that they are facing the same direction that they are thrown and they blast in that direction.
And here's the other .lua file (ClaymoreDeploy.lua):
Code:
function Create(self)
self.alliedTeam = -1;
end
function Update(self)
if self.ID ~= self.RootID then local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then self.alliedTeam = ToActor(actor).Team; end end
if self:IsActivated() and self.ID == self.RootID then
local explosive = CreateMOSRotating("Particle Active Claymore"); explosive.Pos = self.Pos; explosive.Vel = self.Vel; explosive.RotAngle = self.RotAngle; explosive.Sharpness = self.alliedTeam; MovableMan:AddParticle(explosive);
self.ToDelete = true;
end
end
I'm not very good at coding, so I would appreciate some help.
Thu Mar 12, 2015 12:42 am
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
Re: How to flip placed TDExplosives by placement direction?
Try using this for the ClaymoreDeploy script:
Code:
function Create(self)
self.alliedTeam = -1;
end
function Update(self)
if self.ID ~= self.RootID then local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then self.alliedTeam = ToActor(actor).Team; end end
if self:IsActivated() and self.ID == self.RootID then
local explosive = CreateMOSRotating("Particle Active Claymore"); explosive.Pos = self.Pos; explosive.Vel = self.Vel; explosive.RotAngle = self.Vel.AbsRadAngle; explosive.Sharpness = self.alliedTeam; MovableMan:AddParticle(explosive);
self.ToDelete = true;
end
end
The line that was changed was
explosive.RotAngle = self.RotAngle;
to
explosive.RotAngle = self.Vel.AbsRadAngle;
Sun Mar 15, 2015 10:58 pm
BlueComet24
Joined: Sun Mar 08, 2015 11:57 pm Posts: 8
Re: How to flip placed TDExplosives by placement direction?
Thanks, CaveCricket. I'm not currently at my CC computer, but I'll give that a try when I am. I appreciate it.
Mon Mar 16, 2015 3:10 am
BlueComet24
Joined: Sun Mar 08, 2015 11:57 pm Posts: 8
Re: How to flip placed TDExplosives by placement direction?
Hmm, I tried replacing that line with the one you changed, and now when I throw a claymore to the left, it's upside-down and the blast still goes to the right. How I'd like it is for the image to be flipped horizontally when thrown to the left (and rotated based on up/down direction), and for the blast to go in the direction the claymore is facing. Do you know how to do this? Thanks.
Tue Mar 17, 2015 2:31 am
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
Re: How to flip placed TDExplosives by placement direction?
After a bit of testing, it seems that the velocity of gibs no longer appear to rotate with the parent object, which is odd.
Here's showing that the mines are rotating properly:
With this modified script (ClaymoreSet.lua) (red lines not included):
Despite this not working, things that use directional blasts like the Ronin RPG-7 still work, so I'm a bit confused. Only thing I can suggest is either using the same explosion style as the RPG-7 (one of the gibs is an emitter that launches the damage particles), or using an emitter for the damage particles and spawning it with Lua when the mine is detonated.
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