My nextbot NPC, when using it's shooting animation does not point at the player, and if they fly up or down it also just stays looking at the ground...how would I make him look at the player being targeted when shooting his gun? I am not sure if this requires bone manipulation or just a simple function to run...kind of lost on this one.
self.loco:FaceTowards(entitytofacetowards)
Run it in your behavior coroutine.
I have that already, moreso mean if I noclip or go up a hill it's body moves to match where I am.
[editline]22nd December 2013[/editline]
Keeps staring at the same spot, while facing me.
[editline]22nd December 2013[/editline]
I tried using FaceTarget or something along those lines, but it just made his entire model pivot from his feet, with no actual motion on the NPC's part =p
Is it potentially the model I am using or is it because I am using nextbot to create the bot, so I need to take special measures to make the arms and head follow the person he is shooting at?
bump, still having this problem (sorry for self bumping again, but it's been 3 days) he faces me, but does not LOOK at me, and his arms don't move to match his targets position the bullets just shoot at an angle..
Did you try SetEyeAngles?
[QUOTE=JetBoom;43314295]Did you try SetEyeAngles?[/QUOTE]
He needs to use SetPoseParameter with aim_pitch and aim_yaw
That would be my next thing to try but I'm sure garry already programmed something to face targets.
[QUOTE=JetBoom;43315332]That would be my next thing to try but I'm sure garry already programmed something to face targets.[/QUOTE]
He expects you to use FaceToward with a coroutine.yield() to halt it until it is finished, but it doesn't move the head or the arms. If I had the code available to make it aim towards a guy I would post it here.
Is that aim_yaw and aim_pitch something that needs to be put into a model or there by default? I am using the master chief NPC model off of the workshop. I read up on how to use it just unsure how to set it for a custom npc model through nextbot..
[QUOTE=KevinnTCG;43318951]Is that aim_yaw and aim_pitch something that needs to be put into a model or there by default? I am using the master chief NPC model off of the workshop. I read up on how to use it just unsure how to set it for a custom npc model through nextbot..[/QUOTE]
It should be on there if it's an NPC model.
Alright thanks, ill look into it =)
How would I go about setting the pitch and yaw to the position of the HEAD bone on a player it is targeting?
Been looking up how to use angles which is what I am assuming I need, will put more thought into it later because I am trying to make something else at the moment =p
[QUOTE=KevinnTCG;43328473]How would I go about setting the pitch and yaw to the position of the HEAD bone on a player it is targeting?
Been looking up how to use angles which is what I am assuming I need, will put more thought into it later because I am trying to make something else at the moment =p[/QUOTE]
When I have the code available I'll post it here.
Anyone else have any idea about this..don't want to sound impatient but I am looking forward to getting this working so I can move on to a different NPC pet I am making =p
[code]
function ENT:GetYawPitch(vec)
--This gets the offset from 0,2,0 on the entity to the vec specified as a vector
local yawAng=vec-self:EyePos()
--Then converts it to a vector on the entity and makes it an angle ("local angle")
local yawAng=self:WorldToLocal(self:GetPos()+yawAng):Angle()
--Same thing as above but this gets the pitch angle. Since the turret's pitch axis and the turret's yaw axis are seperate I need to do this seperately.
local pAng=vec-self:LocalToWorld((yawAng:Forward()*8)+Vector(0,0,50))
local pAng=self:WorldToLocal(self:GetPos()+pAng):Angle()
--Y=Yaw. This is a number between 0-360.
local y=yawAng.y
--P=Pitch. This is a number between 0-360.
local p=pAng.p
--Numbers from 0 to 360 don't work with the pose parameters, so I need to make it a number from -180 to 180
if y>=180 then y=y-360 end
if p>=180 then p=p-360 end
if y<-60 || y>60 then return false end
if p<-80 || p>50 then return false end
--Returns yaw and pitch as numbers between -180 and 180
return y,p
end
--This grabs yaw and pitch from ENT:GetYawPitch.
--This function sets the facing direction of the turret also.
function ENT:Aim(vec)
local y,p=self:GetYawPitch(vec)
if y==false then
return false
end
self:SetPoseParameter("aim_yaw",y)
self:SetPoseParameter("aim_pitch",p)
return true
end
[/code]
This was taken from the SWEP Turret.
Sorry, you need to Log In to post a reply to this thread.