datdude3Join Date: 2010-04-23 Post Count: 577 |
How?? I know it has something to do with cframe but I just
can't wrap my mind around it. |
|
|
Camera.CoordinateFrame = Part.CFrame:toWorldSpace(CFrame.Angles(math.sin(i), math.cos(i), 0))
...I believe... |
|
datdude3Join Date: 2010-04-23 Post Count: 577 |
toWorldSpace what does that mean exactly? (math.sin(i), math.cos(i), 0)) also this? |
|
|
ShungTzuJoin Date: 2014-06-14 Post Count: 959 |
What is i? |
|
|
any number...
for i = 1,360 do
print("I am i! ", i)
end |
|
instawinJoin Date: 2013-06-04 Post Count: 8777 |
^ |
|
instawinJoin Date: 2013-06-04 Post Count: 8777 |
that ^ was directed to shung, i wanted to know what i was as well |
|
Ace23333Join Date: 2011-11-20 Post Count: 1341 |
Man I would rather spin an object than camera, much easier script, just CFrame model/part |
|
instawinJoin Date: 2013-06-04 Post Count: 8777 |
|
|
ShungTzuJoin Date: 2014-06-14 Post Count: 959 |
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. |
|
|
I was going to do math.rad, but i had the feeling OP was confused enough... |
|
ShungTzuJoin Date: 2014-06-14 Post Count: 959 |
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? |
|
ShungTzuJoin Date: 2014-06-14 Post Count: 959 |
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. |
|
ShungTzuJoin Date: 2014-06-14 Post Count: 959 |
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? |
|
chimmihcJoin Date: 2014-09-01 Post Count: 17143 |
-- 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 |
|
ShungTzuJoin Date: 2014-06-14 Post Count: 959 |
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? |
|
chimmihcJoin Date: 2014-09-01 Post Count: 17143 |
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. |
|
ShungTzuJoin Date: 2014-06-14 Post Count: 959 |
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. |
|