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: Camera rotation around an object

Previous Thread :: Next Thread 
datdude3 is not online. datdude3
Joined: 23 Apr 2010
Total Posts: 577
28 Jul 2015 09:21 PM
How?? I know it has something to do with cframe but I just
can't wrap my mind around it.
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
28 Jul 2015 09:25 PM
Camera.CoordinateFrame = Part.CFrame:toWorldSpace(CFrame.Angles(math.sin(i), math.cos(i), 0))

...I believe...
Report Abuse
datdude3 is not online. datdude3
Joined: 23 Apr 2010
Total Posts: 577
28 Jul 2015 09:27 PM
toWorldSpace what does that mean exactly? (math.sin(i), math.cos(i), 0)) also this?
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
28 Jul 2015 09:32 PM
http://wiki.roblox.com/index.php?title=ToWorldSpace#Methods
http://wiki.roblox.com/index.php?title=Function_dump/Mathematical_functions#math.sin
http://wiki.roblox.com/index.php?title=Function_dump/Mathematical_functions#math.cos
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
28 Jul 2015 09:39 PM
What is i?
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
28 Jul 2015 09:40 PM
any number...

for i = 1,360 do
print("I am i! ", i)
end
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
28 Jul 2015 09:40 PM
^
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
28 Jul 2015 09:41 PM
that ^ was directed to shung, i wanted to know what i was as well
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
28 Jul 2015 09:41 PM
Man I would rather spin an object than camera, much easier script, just CFrame model/part
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
28 Jul 2015 09:42 PM
anyway OP, take a look at this article:

http://wiki.roblox.com/index.php?title=Camera_manipulation#math.acos.28x.29
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
28 Jul 2015 10:01 PM
It's meaningful to the CFrame if you put the sin and cos into math.rads, but as long as i is any number, it's meaningless to everyone else, but then trying to pass a sin and a cos directly into a finished CFrame is just a monkey wrench. They're used to derive the final matrix.
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
28 Jul 2015 10:03 PM
I was going to do math.rad, but i had the feeling OP was confused enough...
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
29 Jul 2015 03:38 PM
Alright, so, does anyone know the correct answer to this question. I can make a model rotate and set the CoordinateFrame(<--ugh) to the CFrame of a part in the model, which yields the desired effect but is not the correct answer.

Who knows how to make the camera rotate around a fixed point at a fixed distance without referencing the CFrame of any other part?
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
29 Jul 2015 09:59 PM
bump


I thought about writing out n explanation of how and why nearly all wiki entries on the subject of CFrames are almost completely useless, but that would waste more time than I wasted reading them all several times.
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
29 Jul 2015 11:22 PM
So, does anyone know how to make the camera rotate around a fixed point at a fixed distance without referencing the CFrame of any part?
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
29 Jul 2015 11:39 PM
-- This should work
-- I didn't test because I wrote it on my phone
-- I might have got the axis to edit wrong


local MiddlePos = Vector3.new() -- Position to be focused at
local DistFromPos = 20 -- Distance from position

while true do
local angle = ((tick()*90)% 360) -- Change the 90 to change how fast it spins
wait()
cam.CoordinateFrame = CFrame.new(MiddlePos.X,MiddlePos.Y,MiddlePos.Z) *
CFrame.Angles(0,math.rad(angle),0)*
CFrame.new(DistFromPos,0,0)
end
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
30 Jul 2015 01:28 AM
Very nice!

I played with it a bit, and this

while true do
local angle = ((tick()*90)% 360) -- Change the 90 to change how fast it spins
wait()
p1.CFrame = CFrame.new(MiddlePos.X,MiddlePos.Y,MiddlePos.Z) *
CFrame.Angles(0,math.rad(angle),0)*
CFrame.new(0,0,DistFromPos)
end

works, as long as the position of the thing circling is on the same vertical plane as MiddlePos, but we usually want to be looking down(or up sometimes) at the thing point we're circling.

This;

((tick()*90)% 360)

is amazing. Where do I go to find the meaning of "%" as you used it there?
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
30 Jul 2015 02:40 AM
Sorry for the late response.

https://en.m.wikipedia.org/wiki/Modulo_operation

% is the modulo operator.

It acts like / except it returns the remainder.
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
31 Jul 2015 12:09 AM
Okay, I see; you cause the remainder to be within a range you construct, so that it arrives at the lowest portion of that potential remainder at the interval following the one on which it's total has been met or exceeded.

I still can't figure out, though, how to make it face MiddlePos from above or below it without setting it that way, arbitrarily, beforehand, and omitting the positioning CFrame from the equation.
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