Exactly as title says. How would I rotate a model towards a certain position on the map, say Vector3.new(0, 0, 0) etc.
Does your model have a primary part?
Use CFrame.lookAt on the model’s RootPart (RootMart must be connected to every other part in the model, them being unanchored and the root being anchored)
Yes it does. Basically I have a dart and when it hits a player, I weld it to whatever part of the player it hit(Left Arm, Right Arm etc). However, it doesn’t face the direction it came from, so I’m trying to figure out how to make it so that it does.
Example:
You could also use the align position and align rotation constraints
Could you demonstrate this? Here’s my code for reference.
local Weld = Instance.new("Weld")
Weld.Parent = bullet.PrimaryPart
Weld.Part0 = hit
Weld.Part1 = bullet.PrimaryPart
local WeldingCfr = CFrame.new(m)
local ObjectCframe = hit.CFrame:ToObjectSpace(WeldingCfr):Inverse()
Weld.C1 = ObjectCframe
What is the part you’re trying to rotate?
bullet.PrimaryPart.CFrame = CFrame.lookAt(bullet.PrimaryPart.Position,hit.Position)
For some reason doing this completely destroys whatever was hit.
What do you mean by “destroys”? Could you send a video? Does it destroy in the meaning of :Destroy()
?
Try doing it before you weld the bullet.
I did. Here’s my current code.
bullet.PrimaryPart.CFrame = CFrame.lookAt(bullet.PrimaryPart.Position,hit.Position)
bullet.PrimaryPart.Anchored = false
local Weld = Instance.new("Weld")
Weld.Parent = bullet.PrimaryPart
Weld.Part0 = hit
Weld.Part1 = bullet.PrimaryPart
local WeldingCfr = CFrame.new(m)
local ObjectCframe = hit.CFrame:ToObjectSpace(WeldingCfr):Inverse()
Weld.C1 = ObjectCframe
Unanchoring the RootPart is not needed. What is your bullet tree (how it’s structured)? Are there other parts not welded the the RootPart?
This is what it looks like:
If I don’t anchor the part then it ends up moving whatever it hit:
https://gyazo.com/b42b9a65de385b2ac4fb94168968933c
Ok. Try making all of the Yellow Dart parts un-can-collide-able, and unanchored. Make the RootPart of the Yellow Dart Anchored, and try again.
Still the same result for some reason. Do you think it may be the way it’s welded? I feel as if I might need to change something, but I don’t know what.
Try using a WeldConstraint instead of a Weld.