I have a small issue where on my towers (See below), the enemy is meant to path find to that red dot. With the ‘crossbow tower’ this is done correctly.
However for most other builds the pathfind is wayyy down below for some reason, despite using the same math and having from what ive seen, the exact same orientation when placed, being 0,-90,0 for all builds, both on its primarypart and the model.
in the last image on the side, it accurately does the Y vector based on its orientation, but its still WAY UNDER the actual build
local targetcframe,modelsize = model:GetBoundingBox()
local yaxis = targetcframe.YVector * (modelsize.Y / targetmultiplier)
local position = (target.Position - yaxis)
The target multiplier is 2.2 (2 would mean the absolute bottom position internally of the models height, I want it slightly above so 2.2)
Its at 2.2 for every single build, even the ones where its offset massively but i do not understand why
for debugging (the red dot) this is the code i run
local primary_part = model
local new_part = Instance.new("Part")
local highlight = Instance.new("Highlight")
highlight.Parent = new_part
highlight.Adornee = new_part
highlight.FillTransparency = 1
highlight.OutlineTransparency = 0
highlight.OutlineColor = Color3.new(1, 0, 0)
new_part.Size = Vector3.new(0.5,0.5,0.5)
new_part.Position = position
new_part.Anchored = true
new_part.BrickColor = BrickColor.new("Bright red")
new_part.Parent = primary_part
I would like if anyone knows a more reliable way to do this exact same thing, to share code which potentially works, or to adapt what I have, and if possible to make it use fewer resources as I run this on the server quite often for each npc.