Re: Help - Homing for the head
Hmm I use "local raycast = SceneMan:CastMORay(...)" to get a MO in the line of sight.
How to check wether it is a AHuman?
Code:
if raycast ~= 255 and ToAHuman(targetID) ~= nil then
this seems not to work :/
EDIT:
This works, but it fails for actors without head like crabs
Code:
local raycast = SceneMan:CastMORay(ToHDFirearm(gun).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(owner):GetAimAngle(true)),owner.ID,0,false,2);
if raycast ~= 255 then
local raycast2 = MovableMan:GetMOFromID(MovableMan:GetMOFromID(raycast).RootID);
if MovableMan:IsActor(raycast2) then
self.target = raycast2;
end
end
EDIT: Solved!
Code:
local raycast = SceneMan:CastMORay(ToHDFirearm(gun).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(owner):GetAimAngle(true)),owner.ID,0,false,2);
if raycast ~= 255 then
local raycast2 = MovableMan:GetMOFromID(MovableMan:GetMOFromID(raycast).RootID);
if raycast2.ClassName == "AHuman" then
self.target = raycast2;
end
end