Is there a way to sort of replicate the mechanic of characters like 1st Prize,Dr Reflex, The Test from Baldi’s Basics? And by the mechanic I mean the feature that depending on the angle, there will be a different sprite of the character.
I mean, yeah you could manually do that if you have the direction the character is meant to be looking, and use that as a basis so you can detect what side of a character you are looking at, and change the texture, but I can’t imagine that would be very efficient.
Maybe you could also have all of the textures exist but invisible, and only show the one you are meant to see? That would most likely solve the problem with loading a ton of textures, though, thats gonna be a lot of sprites id imagine to make it look smooth, (isn’t an issue, just noting thats a lot of art lol).
its intentional not to make it smooth though, thanks for the tip!
Did I correctly answer the question? Would this work for you? Anything else you need?
(maybe I’m also dumb and completely overlooked what you were actually asking)
i kinda need to know how could i define the angle, because i cannot find it anywhere lol. anyway, thanks for the replies
probably just camera orientation minus character orientation, or a different order. I don’t work with orientation, so I’m somewhat guessing, but id imagine you just find the difference between the two orientations.
doom rotation sprites.rbxl (86.8 KB)
Hello, I believe this could help you (go into StarterCharacterScripts > PlayerLogic to view how I did it). My method uses SurfaceGuis that follow the local camera on the X and Z axis, and change their sprites based by the angle you’re viewing them from. Excuse the bad code, this was done a few years ago (before all the EditableImage and other stuff was available). Also I forgot to mention, this allows for up to 8 directional sprites (but you can always modify the math to allow for more).
If you don’t want to bother with opening the place file, here’s the main math behind it:
local function getAngle(root: Part)
local p1 = root.CFrame.Position
local p2 = Camera.CFrame.Position
local vector = p2 - p1
local r0 = math.rad(root.Orientation.Y)
local r1 = r0 < 0 and tau - math.abs(r0) or r0
local a0 = math.atan2(vector.Z, vector.X) + math.pi * 0.5
local a1 = ((a0 < 0 and tau - math.abs(a0) or a0) + r1)
local a2 = (a1 % tau) * 8 / tau
return (math.round(a2) % 8) + 1
end
local function rotateToCam(root_part_check: Part)
local HorizontalCameraLookVectorOnly = Camera.CFrame.LookVector
HorizontalCameraLookVectorOnly = Vector3.new(HorizontalCameraLookVectorOnly.X, 0, HorizontalCameraLookVectorOnly.Z) -- ignores vertical component
if root_part_check.Parent:FindFirstChild('Appearance') then
if root_part_check.Parent:FindFirstChild('Hitbox') then
root_part_check.Parent:FindFirstChild('Appearance').CFrame = CFrame.new(root_part_check.Parent:FindFirstChild('Hitbox').Position, root_part_check.Parent:FindFirstChild('Hitbox').Position + HorizontalCameraLookVectorOnly)
end
end
end
Hope this helps!