So I’m making a 2D fighting game and I want the player 1 to always look to where player 2 is at and same for player 2. So let’s say that Player 1 Is At the left of the screen and player 2 is at the right. Both are looking at each other. And now lets say that player 1 gets at the right of player 2 and now player 1 is at the right of the screen and player 2 is left. Player 1 is now looking left and player 2 is looking right.
I really have on idea on how to make that and hope someone can help me. If you don’t understand what I mean, I can make an example.
Ok so, I’m trying to make all of this work but it won’t. First of all, the player wont even look to player 2 and second, he wont even lock to the position he is looking. He is looking at something random and when I walk away or jump, he looks away instead of doing all of that while he is looking there. It just wont work.
This could probably be achieved with constraints and the physics solver, but I am not too familiar with them. I would personally have some client code make their own character look towards their opponent every heartbeat using CFrame.lookAt
Lazy example thrown together, probably inefficient but works
(LocalScript in StarterCharacterScripts)
local Character = script.Parent
local Root = Character.HumanoidRootPart
local Dummy = workspace.Dummy
local DummyRoot = Dummy.HumanoidRootPart
game:GetService("RunService").Heartbeat:Connect(function()
Character:PivotTo(CFrame.lookAt(Root.Position, Vector3.new(DummyRoot.Position.X, Root.Position.Y, DummyRoot.Position.Z)))
end)