Re: RotateOffset based on LegFG
Ah... My lack of knowledge of lua is showing here... That code sounds like it is more or less what I'm after, but how might I integrate your code into mine (below)? Ideally I want the emitter's rotation to be based on the head, since I want to fire it like a gun, which I really didn't make clear in my description - rather than making a permanent addition to my leg consisting of an emitter, I'm trying to change a code which fires an emitter like a weapon from the head to one which fires it from the leg. The problem is that if I position it near the leg by offsetting it, it flies off when I move my head.
My difficulty in fixing it myself is that I don't quite understand how to define more than one body part for the object (this is my first attempt at editing an lua), which would be necessary for me to allow the emitter to rotate with the head.
I'm not sure why you couldn't open the lua, so I pasted it here. Thanks!
Code:
function Create(self)
local thisID = ToActor(self).ID
local MoObj
for i = 1, MovableMan:GetMOIDCount() do
if (i ~= thisID) and (MovableMan:GetRootMOID(i) == thisID) then -- an obj without a parent has ID == RootID
MoObj = MovableMan:GetMOFromID(i)
if MoObj.PresetName == "Maximilian Head" then -- Name of the actor's HEAD here.
self.Head = ToAttachable(MoObj)
break
end
end
end
self.fired = false;
end
function Update(self)
if self:GetController():IsState(Controller.WEAPON_FIRE) and self.Head:IsAttached() and self.fired == false then
local Emitter = CreateAEmitter("Maximilian Talon", "Maximilian.rte") -- Name of the emitter and .rte here.
Emitter.Vel = self.Vel
if self.HFlipped then
Emitter.RotAngle = self.Head.RotAngle + 3.1415
else
Emitter.RotAngle = self.Head.RotAngle
end
Emitter.Pos = self.Head.Pos + self.Head:RotateOffset(Vector(0, 36)) -- Use self.EyePos instead? Probably no need.
MovableMan:AddParticle(Emitter)
self.fired = true;
end
if self:IsPlayerControlled() == false then
self:GetController():SetState(Controller.BODY_CROUCH, false);
end
local Ctrl = self:GetController();
if Ctrl:IsState(Controller.BODY_JUMPSTART) then
else
self.AngularVel = self.AngularVel * 0.75;
end
if not self:GetController():IsState(Controller.WEAPON_FIRE) then
self.fired = false;
end
end