|
| 06 Dec 2015 02:09 PM |
I'm currently trying with a fast loop always updating the cameras position to follow the part. However once the camera position changes the part moves before the next change and it looks weird like its not synced.
How do I make a scriptable camera follow a moving object and remove this problem? |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 02:10 PM |
| Hook it to RenderStepped, or use Interpolate to make it a smooth transition no matter what. |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 02:12 PM |
| Thank you, I'll look into that. If you could write an example i'd appretiate it. |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 02:20 PM |
If the Object in question is controlled by the local player (Such as it being part of the Character, or a LocalPart, etc) then all you really need to do is set it like this.
game:GetService("RunService").RenderStepped:connect(function() -- Set position here. end)
If the Object is controlled by the server, you will need to interpolate, because latency, network data needing to be re-sent due to being corrupt, and stuff like that. |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 02:20 PM |
Here's my script:
local camera = workspace.CurrentCamera local player = game.Players.LocalPlayer local mouse = player:GetMouse() local character = workspace:WaitForChild(player.Name) local torso = character:WaitForChild("Torso") local hum = character:WaitForChild("Humanoid")
local Frame = game:GetService("RunService")
camera.CameraType = "Scriptable" Frame.RenderStepped:connect(function() if (hum.Health == 0) then return end camera:Interpolate( CFrame.new(torso.Position.X - 0.001, torso.Position.Y + 50, torso.Position.Z), CFrame.new(torso.Position.X, 0, torso.Position.Z), 0.03 ) end)
-------------- And here's how the final result looks:
http://www.roblox.com/games/179250490/Model-Making-Place-Showcase |
|
|
| Report Abuse |
|
|
| |
|