How can I make player 1 always look at player 2 and player 2 always look at player 1?

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.

u can try use cframe.look at to make player look eachother

1 Like

Have you tried this solution, I searched up “roblox make npc face player”. Although it’s for an NPC

This is also what I found by searching “roblox fighting game make player face opponent” which should be more closer to what you are looking for.

It also uses CFrame.new(pos1, pos2) similar to CFrame.lookAt(pos1, pos2) to the above post for an npc.

1 Like

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.

Is the face each other process inside a loop or something like run service’s heartbeat?

1 Like

I’m talking about this script, I don’t really know how it works tho.

But, now that I search body gyro, I found out that AlignOrientation is better, I think. It was stated in the document.

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)

(GIF for reference)
https://gyazo.com/0f8a90f4f92ca6e3387bcde7884c4dbc

3 Likes

I can’t find on how to mention player 1 and 2.

1 Like