方法
StarterCharacterScripts の下にLocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local SetCameraType = ReplicatedStorage:WaitForChild("SetCameraType");
local CurrentCamera = workspace.CurrentCamera;
local changedCamera = false;
if not changedCamera then
SetCameraType.OnClientEvent:Connect(function(cameraPart)
CurrentCamera.CameraType = Enum.CameraType.Scriptable;
CurrentCamera.CFrame = CurrentCamera.CFrame + CurrentCamera.CFrame.LookVector * (-2);
wait(1)
CurrentCamera.CameraType = Enum.CameraType.Custom;
end)
end
Partの下のScript:
local Players = game:GetService("Players");
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local part = script.Parent;
local cameraPart = workspace:FindFirstChild("CameraPart");
local setCameraType = Instance.new("RemoteEvent");
setCameraType.Name = "SetCameraType";
setCameraType.Parent = ReplicatedStorage;
part.Touched:Connect(function(hit)
local Character = hit.Parent;
local Humanoid = Character:FindFirstChild("Humanoid");
if Humanoid then
local Player = Players:GetPlayerFromCharacter(Character);
setCameraType:FireClient(Player, cameraPart);
end
end)
参考
https://devforum.roblox.com/t/how-do-i-change-currentcamera-cframe-on-part-touch/915727/9