Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

lookVector changes on CFramed parts?

Asked by
Elixcore 1337 Moderation Voter
5 years ago
Edited 5 years ago
local from = Camera.CoordinateFrame.p
        local to = mouse.Hit.p
        local ignore = {workspace}
        local ray = Ray.new( from, (to - from).unit * 1000)
        local newTarget, newHit = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
        local hrp = plr.Character:WaitForChild("HumanoidRootPart")
        hrp.CFrame = CFrame.new(hrp.Position, newHit - Vector3.new(0,newHit.Y,0) + Vector3.new(0, hrp.Position.Y, 0) )

The ray in the script above is applied to the LocalPlayer's HumanoidRootPart every Step and looks something like this

all nice and dandy, right? ok now the problem is this.

local tween = game:GetService("TweenService"):Create(part, tweenInfo, {Position = plr.Character.Head.CFrame.lookVector * 250})      
            tween:Play()

if I try to tween a part according to the head's lookVector it works fine... as long as I don't press A, S or D.

If I press either of them the lookVector goes off-track, despite the animation playing and the head being straight in place.

This is it normally (how it's supposed to be)

And this is how it is when you press A, S or D

Extra notes: This happens to all parts, including LowerTorso, UpperTorso, HumanoidRootPart, Head. This is not because the camera script is a localscript, I already tried executing that code in a localscript and the same thing happens with A, S, D.

I have tried a lot of things, such as Anchoring, changing the walkspeed to 0, stopping the animations, but as long as you press one of those 3 buttons the lookVector will change.

I am getting desperate because I am probably going to have to scrap the move (along with many others) or even the entire aiming system if I don't find a way to fix it.

0
try {Position = part.Position + plr.Character.Head.CFrame.lookVector * 250} GoldAngelInDisguise 297 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

i notice that your torso changes accordingly to the animation, so either change the animation, or even better, use the cframe of the head or the camera

0
I mean you no offense but this is possibly the worst answer I've seen yet. Elixcore 1337 — 5y
0
It shows how incapable you are and how you paid no attention to what I've wrote. Elixcore 1337 — 5y
Ad

Answer this question