Another question I had:
How would you make it so you could hold the R key and move your mouse left and right to customize the rotation of the model in any degree, instead of being limited to 45/90 degree rotation?
To do this we only really need to adjust and calculate the rotation argument in the :CalcPlacementCFrame()
method.
-
Adjust our rotation key binding such that when holding down the
R
key we have a boolean that tells us if we should be rotating or not. -
If we aren’t rotating we move around the object as per usual. If we are rotating we save the last position our object was placed at and use that as the position of our placement. We’ll call this the pivot point.
-
We calculate the difference between our mouse and that pivot point and then convert it to the object space of our canvas part’s surface. This ensures that the rotation is relative to what we’re placing on.
-
With that object space vector we can find the angle of rotation with
math.atan2
and update the rotation parameter accordingly.
This is what that looks like:
All the changes are in the ClientPlacement
localscript. That should be enough to get you going. Enjoy!
placement rotation.rbxl (25.4 KB)