Movement/Animations

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)

image

1 Like

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.

If the character turns to the x-axis while walking, its front side will be the x-axis.
same applies to the y-axis.

Do you mean that the arms don’t properly adjust to when you turn because of absolute coordinate values?

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)

i cant upload video im gonna find in youtube wait

like this


and

This could help you with the swaying, obviously replace the camera cframe with the viewarm model

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.

1 Like

I will play the animation when it goes to the right anyway, but I don’t know how to write in the code that the character goes right

but i don’t know how i need to do something for the video below

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.

1 Like

I haven’t used Assembly Linear Velocity before, so I’ll look into it, but if there is an easier or reliable code, others can write it. and thanks

1 Like

I solved the shaking thing. I’m thinking of playing animation while moving using userinputservice and humanoid.speed. thanks for the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.