• Help with positioning a prop that follows a playermodel bone
    7 replies, posted
Hi, I'm trying to make a ttt addon. Its an ankle monitor that a detective places on the suspect. To spare you the details, I'm stuck on the part where I'm supposed to place the monitor. I got the position of the bone using GetBonePosition, and the bone number is 24 (left leg). I've set the position of the monitor to that leg, and set it to follow the bone (FollowBone). The problem is that the angles and positions don't make any sense. The starting angle is weird, and the position is a bit off (next to the leg), and changing the position and angles isn't giving me the desired results. Does anyone know why that is, and if there is an easier way to set this up. Brute forcing the values until the monitor is where I want it to be is something I definitely want to avoid. Any help is appreciated. Thanks in advance.
Entity/GetBonePosition it also returns an angle
GetBonePosition is acting a little bit weird and laggy.
I know, but I've still had no luck with it. I tried forwarding that angle to the prop, but still nothing. I tried subtracting the values hoping I would get my props neutral position, but no luck.
post code
Try this: Entity/FollowBone
local vPos, aAng = ply:GetBonePosition(24) local prop = ents.Create("prop_dynamic") prop:SetCollisionGroup(COLLISION_GROUP_NONE); prop:SetModel("models/ancle_monitor/ancle_monitor.mdl") prop:FollowBone(ply, 24) prop:SetPos(vPos + Vector(0,0,4)) prop:SetAngles(Angle(-90, -148, 90)) prop:Spawn() That is the code that maybe kind of works. The problem is that setting positions changes the angles, and vice versa. I've tried setting local angles and positions, but no luck there. In all honesty, I'm quite new to this, so its entirely possible that I did something wrong. I'm testing this on a bot filled server, and some bots have the monitor attached properly, and some don't (using the code above). https://files.facepunch.com/forum/upload/350934/18947f0a-8c7e-4db0-9a9c-7153c7e004d3/20181120122320_1.jpg
What did your SetLocalPos code look like? If all you did was change SetPos to SetLocalPos, you have to get rid of the vPos and only pass the Vector(0, 0, 4) to the function. -- SetLocalPos changes the local position relative to the bone's position
Sorry, you need to Log In to post a reply to this thread.