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

using BodyGyro vs CFrame in?

Asked by 5 years ago

Hey I was working on a small project and in the project I needed to turn the player to face the mouse. I saw that I could do this using BodyGyro but it was too slow so I went the CFrame route.~~~~~~~~~~~~~~~~~ function turn(mouse) local pointto = mouse.Origin local rotation = nil

local player = script.Parent.Parent
while true do

--print(rotation) rotation = pointto - mouse.Origin.p wait(1) player.UpperTorso.CFrame = rotation + player.UpperTorso.CFrame.p + Vector3.new(0,1,0) end end ~~~~~~~~~~~~~~~~~ The turn fuction rotates the player on the Y axis only to face the mouse; well that is what it should do. Can someone tell me why the player is moving forward in a jerky manner and why the player only faces the mouse upon function call and no other time?

Also, what are the benefits and disadvantages of using BodyGyro and CFrame for this sort of task. I am aiming to make the turn swiftly but not choppily. Are there any other methods of doing this task? Thanks

0
The jerky motion might be from the while loop, even if you use a wait() it tends it be very choppy in game. Try using https://wiki.roblox.com/index.php?title=API:Class/RunService/RenderStepped climethestair 1663 — 5y
0
Oh srry, I should have clarified that the choppy motion was not the problem. The problem was the jerky motion where the player teleport-translates across the map. The second part was that the player only turns when the function is initially called or recalled, but when called/recalled it only snaps once to direction of mouse. fa_QURobloxXD 29 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

So, does anyone know what I am doing wrong?

Ad

Answer this question