Hi fellow developers, i just created a 2 player cutscene animation.(cutscene not yet added) but i ran into some issues.
-
What do you want to achieve? I want to align both the characters to exactly how it was in blender
-
What is the issue? Both the characters dont align well in studio but they do in blender
-
What solutions have you tried so far? I tried pivoting the target’s cframe to the User’s cframe and offsetting it by 3 studs on the z axes but it doesnt work.I also tried making the target face the user but that doesnt work as well.
this are the videos:
Studio:
Blender:
Local Script:
local enemyHumanoidRootPart = data.EnemyHumanoid.Parent.HumanoidRootPart
local HumanoidRootPart = data.Humanoid.Parent.HumanoidRootPart
task.wait(0.5)
enemyHumanoidRootPart.CFrame = HumanoidRootPart.CFrame + (HumanoidRootPart.CFrame.LookVector * Vector3.new(1.5, 0, -2.5))
enemyHumanoidRootPart.CFrame = CFrame.new(enemyHumanoidRootPart.Position, HumanoidRootPart.Position)
local UserAnimation: AnimationTrack = data.Humanoid.Animator:LoadAnimation(data.UserAnimation)
local TargetAnimation = data.EnemyHumanoid.Animator:LoadAnimation(data.TargetAnimation)
UserAnimation:Play()
TargetAnimation:Play()
Server Script:
local function EnableCollisions(user, target)
for _, part in user:GetDescendants() do
if part:IsA("BasePart") then
part.CollisionGroup = "Player"
end
end
for _, part in target:GetDescendants() do
if part:IsA("BasePart") then
part.CollisionGroup = "Player"
end
end
user.Humanoid.WalkSpeed = 12
user.Humanoid.JumpHeight = 7.2
user.Humanoid.AutoRotate = true
target.Humanoid.WalkSpeed = 12
target.Humanoid.JumpHeight = 7.2
target.Humanoid.AutoRotate = true
end
local function DisableCollisions(user, target)
for _, part in user:GetDescendants() do
if part:IsA("BasePart") then
part.CollisionGroup = "User"
end
end
for _, part in target:GetDescendants() do
if part:IsA("BasePart") then
part.CollisionGroup = "Target"
end
end
user.Humanoid.WalkSpeed = 0
user.Humanoid.JumpHeight = 0
user.Humanoid.AutoRotate = false
target.Humanoid.WalkSpeed = 0
target.Humanoid.JumpHeight = 0
target.Humanoid.AutoRotate = false
end
local function Cutscene(hitbox: Part, data)
local isNpc = false
--Detect hit
--Play Cutscene
--Set Camera Position
local connection
connection = hitbox.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid").Health >= 1 and hit.Parent ~= data.Character then
print(hit.Parent.Name)
local User = Players:GetPlayerFromCharacter(data.Character)
local Target = Players:GetPlayerFromCharacter(hit.Parent)
if Target == nil then isNpc = true end
katanaRemote:FireClient(User, "DisableRun")
local remoteData = {
UserAnimation = data.UserAnimation,
TargetAnimation = data.TargetAnimation,
Humanoid = data.Character.Humanoid,
EnemyHumanoid = hit.Parent.Humanoid,
HumanoidRootPart = data.Character.HumanoidRootPart,
EnemyHumanoidRootPart = hit.Parent.HumanoidRootPart
}
onCutsceneActivated(User, Target, isNpc, remoteData) --Disables collisions and fires remote to both of the clients
destroyWeld(data.Character.HumanoidRootPart, "DS Weld", 0)
hitbox:Destroy()
connection:Disconnect()
end
end)
endlocal function Cutscene(hitbox: Part, data)
local isNpc = false
--Detect hit
--Play Cutscene
--Set Camera Position
local connection
connection = hitbox.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid").Health >= 1 and hit.Parent ~= data.Character then
print(hit.Parent.Name)
local User = Players:GetPlayerFromCharacter(data.Character)
local Target = Players:GetPlayerFromCharacter(hit.Parent)
if Target == nil then isNpc = true end
katanaRemote:FireClient(User, "DisableRun")
local remoteData = {
UserAnimation = data.UserAnimation,
TargetAnimation = data.TargetAnimation,
Humanoid = data.Character.Humanoid,
EnemyHumanoid = hit.Parent.Humanoid,
HumanoidRootPart = data.Character.HumanoidRootPart,
EnemyHumanoidRootPart = hit.Parent.HumanoidRootPart
}
onCutsceneActivated(User, Target, isNpc, remoteData) --Disables collisions and fires remote to both of the clients
destroyWeld(data.Character.HumanoidRootPart, "DS Weld", 0)
hitbox:Destroy()
connection:Disconnect()
end
end)
end