generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: math.atan2

Previous Thread :: Next Thread 
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
26 Dec 2015 08:52 PM
Why doesn't this work, my camera just flips out. I am trying to make the camera trail behind the head, and also have the torso face the mouse.

local User = game.Players.LocalPlayer

repeat wait() until User

local Mouse = User:GetMouse()
local Character = User.Character or User.CharacterAdded:wait()

local Head = Character.Head
local Torso = Character.Torso

local Neck = Torso.Neck
local Shoulder = Torso['Right Shoulder']

local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable

game:GetService('RunService').RenderStepped:connect(function()
local Direction = (Torso.Position - Mouse.Hit.p).unit
Torso.CFrame = CFrame.new(Torso.Position) * CFrame.Angles(0, math.atan2(Direction.X, Direction.Z) + 3.14, 0)
Camera:Interpolate(Head.CFrame * CFrame.new(5, 10, 12), CFrame.new(Head.Position), 1 / 30)
end)

"The butt-hurt is strong with this one" - GuyWithACleverName 2k15.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
26 Dec 2015 08:58 PM
Perhaps because the camera moving causes itself to move more.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
26 Dec 2015 09:01 PM
2Jarod
How do I fix it?

"The butt-hurt is strong with this one" - GuyWithACleverName 2k15.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
26 Dec 2015 09:04 PM
Don't move the camera?
Or just don't do it based on cursor position.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
26 Dec 2015 09:12 PM
I narrowed it down: the problem is that the Camera is receiving the angles of the head, too. How do I stop that?

"The butt-hurt is strong with this one" - GuyWithACleverName 2k15.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image