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: Character freezing problem with RunService?

Previous Thread :: Next Thread 
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 03:37 PM
I found a game-breaking glitch in my script. It's my top down script. For some reason, it doesn't break when you get teleported onto regular parts, but teleporting to terrain breaks your player. Refer to this forum for all issues/troubleshoot attempts: https://forum.roblox.com/Forum/ShowPost.aspx?PostID=210791968

local StarterGui = game:GetService('StarterGui')
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
game.Players.LocalPlayer:WaitForChild('PlayerGui'):SetTopbarTransparency(0)
wait(.5)
while not game.Players.LocalPlayer.Character:FindFirstChild('Head') do wait() end

local cam = workspace.CurrentCamera
cam.CameraType = 'Custom'
cam.CameraType = 'Scriptable'

local RunService = game:GetService('RunService')
while RunService.Stepped:wait() do
local head = game.Players.LocalPlayer.Character:FindFirstChild('Head')
local distance = script.DistanceFromHead.Value
cam.CFrame = CFrame.new(Vector3.new(head.Position.x - 0.001, head.Position.y + distance, head.Position.Z),head.Position)
end
Report Abuse
XCVlll is not online. XCVlll
Joined: 23 Oct 2008
Total Posts: 963
27 Feb 2017 03:41 PM
why don't you just do game:GetService('RunService').Stepped:connect(function() instead of having all those variables you don't even need
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 03:42 PM
that was some good input to a very urgent problem that I need solved to resume my development!!!
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 03:51 PM
bind to render stepped after the camera (look at wiki examples) then and also make the camera not completely 180 degrees and instead aim it slightly forwards because character direction is determined by camera angle and if the camera is 180 degrees it has trouble finding it
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 03:52 PM
before the camera*
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:16 PM
how do i bind renderstepped after the camera?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:17 PM
look it up in the wiki

BindToRenderStepped
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:19 PM
so try setting camera angle to something like 176 instead of 180 or 3 instead of 0.. etc
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:29 PM
Here's what I have now:

local StarterGui = game:GetService('StarterGui')
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
game.Players.LocalPlayer:WaitForChild('PlayerGui'):SetTopbarTransparency(0)
wait(.5)
while not game.Players.LocalPlayer.Character:FindFirstChild('Head') do wait() end

local cam = workspace.CurrentCamera
cam.CameraType = 'Custom'
cam.CameraType = 'Scriptable'

local RunService = game:GetService('RunService')

RunService:BindToRenderStep(cam, Enum.RenderPriority.Camera.Value+1, function()
local head = game.Players.LocalPlayer.Character:FindFirstChild('Head')
local distance = script.DistanceFromHead.Value
cam.CFrame = CFrame.new(Vector3.new(head.Position.x - 0.001, head.Position.y + distance, head.Position.Z),head.Position)
end)




It's still doing the same exact thing as seen here: https://www.youtube.com/watch?v=LE37yoDGEKA
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:30 PM
i already told you to change the angle ..............................................
rotate it backward by about 5 degrees
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:31 PM
i'm not familiar with rotating cframes.

I think you need to use CFrame * CFrame.Angles(vector3)?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:32 PM
floats and doubles are not 100% accurate so a 180/90/-90/360 degree rotation can make the directional vector swap from one side to the other which confuses the characters sense of camera direction
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:33 PM
*-180

and yes

cf * cf = combined cf --order matters
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:36 PM
um what

like I said I'm very new to cframes and that equation you gave me isnt helping
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:37 PM
cframes are generated with position and a rotation matrix

so if you multiply cframes together it will combine them (shift the first one locally then rotate)
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:37 PM
ok so what would I rotate it by then?

CFrame.new(1, 179, 1)?

im lost..
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:38 PM
no
CFrame.Angles( rad_x, rad_y, rad_z) generates a cframe using x,y,z in radians (euler angles to rotation matrix)
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:40 PM
Sooo

cam.CFrame = CFrame.new(Vector3.new(head.Position.x - 0.001, head.Position.y + distance, head.Position.Z),head.Position) * CFrame.Angles()

but what do I put inside CFrame.Angles()?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:42 PM
x, y, z rotation in radians

take higher level math classes or look up what i am telling you because it is very useful
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:42 PM
I'm only in ALG 2 but I assume I need to convert the values I want to radians?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:49 PM
yes so you could try

math.rad(-60)

and move it around from x to y to z until it rotates the camera back, then change it to a less noticable degree and it should fix right up

the reason why this problem can happen is because the camera when it looks straight down, the direction can flip to the other side:

0.9....,0.9....,0.01...


0.9....,0.9....,-0.01... --it flipped over and now the direction is going to be thought of as going the other way
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 04:57 PM
in your opinion, what is the best angle for a top down view that would work?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 04:59 PM
idk just angle it very slightly and lower fov to 10
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
27 Feb 2017 05:04 PM
ok it works but the controls are weird now (I have a feeling the camera is not rotated correctly)

Since my game is top-down, pressing D goes up and S goes right.

Here's my angle:

CFrame.Angles(math.rad(0), math.rad(.1), math.rad(0))
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
27 Feb 2017 05:06 PM
try it at a different angle also 0 is 0 in both radians and degrees

radians are just

degrees * pi / 180

because

360/180 is 2 and 2pi is a full rotation
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