Heya, so i’m making the build tool for my game: Build a killing machine! ™
The question is, I don’t know how to make the rotation relative to the plane you’re building a block on.
Like this:
As you can see, you can rotate the block on another block either on the X direction or the Y direction.
This is my attempt, using the normal of each face of the block:
As seen, it doesn’t rotate properly. I don’t know why. This is the relevant piece of code.
function getPlacementCFrame(primaryPart: BasePart): CFrame
assert(raycastResult, "raycastResult is nil!")
local target: Part = raycastResult.Instance
local hitPosition: Vector3 = raycastResult.Position
local _rotation: CFrame = rotation
if relativeRotation then
local tempCFrame1: CFrame = CFrame.lookAt(Vector3.new(), raycastResult.Normal)
tempCFrame1 = (tempCFrame1 - tempCFrame1.Position)
local tempCFrame2: CFrame = tempCFrame1:ToObjectSpace(rotation)
_rotation = (tempCFrame2 - tempCFrame2.Position)
end
--CFrame.new(raycastResult.Position) * _rotation *
local resolvedCFrame: CFrame = CFrame.new(raycastResult.Position) * _rotation
...
How would you use this? Especially with two axes? (X,Y) I think I have to use :cross somewhere but I do not know the other value of cross other than normal vector.
Gridplacer will do some of the things you are trying to do, the main thing it doesn’t have is collision detection. Also I think this place is uncopylocked and has an example of how to use GridPlacer in ProtoFabriz tool:
Bump. Sorry, I just cannot for the life of me figure out how to do this. Even with the CFrame.fromAxisAngle tip from azqjanna
Let me rephrase: How can we achieve what we saw in the build a boat clip without relying on the rotation of the part itself (only the surface normal)
What I mean by UpVector is the vector which represents the front face. It is probably Y vector but you can just see it by clicking on the part, if the axis of front face is green, it’s Y vector. Sorry but I’m myself learning about CFrames.
I’ve tested this, and this only works on one side (since the normal is different depending on which side you’re raycasting from, it isn’t perpindicular to the other two vectors unless the normal is on the top side)