How can I tell in code that a character is going to the right and how can I send these arms in an animated way in the direction I’m looking (I used tween, but when I went forward it was a problem)
( I can’t upload valorant video it gives an error)
Code and model if you want
local RunService = game:GetService("RunService")
local Plr = game:GetService("Players").LocalPlayer
local Char = script.Parent
wait()
local ViewModel = game:GetService("ReplicatedStorage").CloneObject.Arms:Clone()
ViewModelPrimaryPart = ViewModel.PrimaryPart
ViewModel.Parent = workspace
Plr.CameraMode = Enum.CameraMode.LockFirstPerson
RunService.RenderStepped:Connect(function()
ViewModelPrimaryPart.CFrame = workspace.CurrentCamera.CFrame * CFrame.new(0, -1, -1.6)
for i,v in pairs(ViewModel:GetDescendants()) do
if v:IsA("BasePart") then
v.LocalTransparencyModifier = 0
end
end
end)
Could you detect when the character position on the workspace moves and then when the event runs check which value is moving (like x, y and z). That’s my best guest right now.
the arms are working properly but when i walk to the right i have to play an animation. how can i use in code where character goes right
(im using translate, my english little bad sorry)
Given the system that you’re implementing, you won’t be able to use a simple animation object to achieve what you’re trying to do. This is because the animation will not be reliably translated through different states of movement. You’re going to have to create animations manually with the ViewModel. I’m sure there are many tutorials/packages out there that can help you achieve this.
I don’t know the most effective way to do this - maybe some other people here might be able to tell you.
One way I can think of is to use the character’s PrimaryPart’s AssemblyLinearVelocity and the character’s PrimaryPart’s CFrame orientation to determine how the character is relatively moving. From this relative motion, you’d be able to figure out the exact angle at which the player is moving (from a top-down POV) and consequently which direction the player is moving (e.g. left, right). This solution seems a bit complex for the problem at hand, though. I’ve also never tested the reliability of AssemblyLinearVelocity in the player context either, so you should do some experimentation yourself to figure out the best possible solution.