Keep object flat on a sphere

How can I move an object on a sphere while keeping it FLAT?

I have a sphere and I am trying to replicate movement as shown in Rise of Nations by Hyperant. How can I keep the object FLAT and not clipping/rotating oddly.

When you say “flat” do you mean conforming to the sphere’s actual geometry or are you talking about just having it like “limited” to the sphere’s radius giving the illusion of it being flat on the sphere?

Yes I mean the latter. >> chars limit



Right now it looks like it is sinking. It is meant to stay flat. I’m not sure how to do this.

Use your sphere’s UpVector*Sphere.Size.Y, that is the 0 rotation point. Then for each object that you need to rotate, raycast to the object position CFrame.LookAt(sphere.Position, object.Position).LookVector * Sphere.Size.Y.

Congratulations, now you have a triangle (Centre, 0 rotation point, object point). Calculate the angle that is at the centre point, and you’ve got yourself the correct rotation needed for the object.

local cf = CFrame.lookAt(unitBase.Position,game.Players.LocalPlayer:GetMouse().Hit.UpVector, game.Players.LocalPlayer:GetMouse().Hit.LookVector)*CFrame.Angles(-4.7,-.25,-4.7)

unit:SetPrimaryPartCFrame(cf)

would this work?