How would I rotate parts along vector to face towards another part

I found a couple posts asking this exact question but im looking for a simpler solution
I have tried fromaxisangle and rotating the part by a certain amount but it isnt great, rather than applying rotation i would rather make the part face towards the target instantly
Also, for clarity the vector that the rotation is done on has to stay the same afterwards, so for example the upvector should stay while the look and rightvectors are free to change

ig understand the post very well but if you want to make a part look to another part you can use CFrames

local LookAt = CFrame.new(Part1.Position,Part2.Position) – part 1 will look at part 2

Part1.CFrame = LookAt – part1 will look at part 2

that would not keep the upvector consistent, i dont need the lookvector of the part to be directly on the target, but as close as it can get without changing the upvector

1 Like

i donot know how to do that you can wait for another one to reply

I believe that there is a third parameter for CFrame.lookat for the UpVector.

You could do something like this:

local UpVector = CurrentPart.CFrame.UpVector

CurrentPart.CFrame = CFrame.lookAt(CurrentPart.Position, OtherPart.Position, UpVector)
2 Likes

Tried already, it does not behave in a way that makes this work

edit: this may have given me an idea on how to make it work

currentPart.CFrame = CFrame.fromMatrix(currentPart.Position, (otherPart.Position-currentPart.Position).unit:Cross(currentPart.CFrame.UpVector), currentPart.CFrame.UpVector)

this should work

1 Like

Wizard.

Summary

text minimum

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.