What do you want to achieve?
I want to rotate a part relative to another part.
What is the issue?
Only one of the parts gets rotated correctly since It’s getting rotated on the correct axis.
What solutions have you tried so far?
Tried using some of the CFrame functions like :ToObjectSpace(), but couldn’t figure anything out. Also tried looking for solutions online, but didn’t know what to search since I don’t know what to even call this problem.
poster.Orientation = Vector3.new(0,0, random:NextNumber(-10, 10))
I could get the orientation of the board, but I’d have no idea which axis to add onto to rotate the poster.
This problem is known as rotating to surface normal. Surface normal can be visualized as an arrow standing perpendicular upright on any surface a ray touches. These posts below should help
Alright, so this is a bit wonky and it could definitely been done better but hopefully this satisfies what you’ll use it for.
totally not copy pasting some of code I sent here
local result : RaycastResult
local normal : Vector3
local relative_vector = Vector3.yAxis -- This makes it so it's similar to a user's camera
-- // As far as I know, this might not look pretty with mesh parts
-- // Also checking because I think result.Instance could be terrain
-- // I do not apologize for my use of tern…
Rather than trying to convert this up vector into an angle which is also complicated it’s better to leave it I would rather use @EgoMoose advanced CFrame technique to leave it in terms of vectors.
We can obtain a CFrame rotation to align the current persons “UpVector” to the new surface upvector. Here is an example script and video.
The advantage of this method is that it will allow you to rotate along the new upVector without having to specify a right vector as a CFrame.fromMatrix solution.
…
2 Likes
I think I found the function I need to use from the advanced CFrame post, I’ll see if it works.
cakeycocoa
(StarvinMarvin)
May 2, 2024, 10:11am
#5
Got it to work perfectly, tysm.
system
(system)
Closed
May 16, 2024, 10:12am
#6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.