I am not really sure what code I should try, so for now, I am using ToObjectSpace.
The “Y” direction is like this right?
I have A NPC model, that when I press R, it rotates 45 degrees in the (I think) Y Direction. It works nicely on most surfaces, but on uphill surfaces, The NPC rotates On the Y axis (usually good) but then The NPC’s legs, are like this (the green parts are the legs)
function RotNPC ()
local NPC = --patch to NPC model
local currentPivot = --patch to NPC model:GetPivot()
NPC:PivotTo(currentPivot + Vector3.new(0, 0, 45))
-- also sript / promt triggered :Connect(RotNPC)
Unfortunately, I’m going to sleep now (it’s almost night time), but the problem is probably that you need to make small invisible ones
like steps on the slope so that the tower can stand flat (It looks like something on TDS)
This is not an ideal version, it is something similar to my idea
I am teleporting the model to the mouse position/hit every .05 seconds, I want the base (The blue part ) to always be on top, or an even distance to the top. In the video, a second before it ended, you could see all of the base evenly spaced under the grey part. You know when you rotate a model, and Press L to rotate it based on It’s current rotation? How would I get the Grey part’s rotation, and apply it to the NPC’s rotation?
local MouseTarget = Mouse.Target
local MouseHit = Mouse.Hit
local Target = Plr.TroopTargetUnfinishedPlacement.Value--The model
--Gets the models orientation, and the value of the wanted to increase rotatation
local TargetX = math.rad(MouseTarget.Orientation.X + Target.XRotation.Value)
local TargetY = math.rad(MouseTarget.Orientation.Y + Target.YRotation.Value)
local TargetZ = math.rad(MouseTarget.Orientation.Z + Target.ZRotation.Value)
local NewPart = Instance.new("Part")
NewPart.Anchored = false
Target.YRotation.Value += IncreaseValueRotationValue
NewPart:PivotTo(CFrame.new(MouseHit.Position) * CFrame.Angles(TargetX,TargetY,TargetZ))
local PartCFrame = NewPart.CFrame
I was about to post the same thing. Basically, you can raycast downwards from some part by raycasting from part.Position to part.CFrame.UpVector*-5 or something like that. Then, the raycast result table has something called “normal” it just gives you the unit vector that is perpendicular to the ground. You can then use SetPrimaryPartCFrame accordingly on the npc to get it to rotate correctly.