|
| 22 Dec 2013 11:55 PM |
| So I have an object and a vector3 position. I want to move the object around the point in a circler way. I have a lookvector that the that the object will always be rotated towards. So all I need is a formula that will pivot a object around a point using a lookvector. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 22 Dec 2013 11:56 PM |
What do you mean "around a point" like from an axis or a certain point on the part? If you mean just plain rotate it, just using CFrame.Angles |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:09 AM |
| I want the object to move around a point like a compass. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 12:12 AM |
Just do part.CFrame = part.CFrame * CFrame.Angles(0, rotation amount in radians, 0) |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:18 AM |
| That just rotates the object I'm talking about a compass that draws circles. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 12:21 AM |
local point = Vector3.new(x, y, z) local object = workspace.Blah local offset = 10
for i = 0, 180 do --180 deg. object.CFrame = CFrame.new(point) * CFrame.Angles(0, math.rad(1), 0) * CFrame.new(0, 0, offset) end
If this is what you are talking about |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:31 AM |
Yes that's what I'm talking about but now I need to do it with a lookvector. I need the rotating object to get as close as it can to the look vector with going out of its radiuses. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 12:34 AM |
Here's 1 thing:
local startLookVector = the current lookVector local endLookVector = the lookVector you want it to go to local off = endLookVector-startLookVector local angle = math.atan2(off.X, off.Z) + math.pi
for i = 0, 1, 0.1 do --a full rotation part.CFrame = CFrame.new(point.Position) * CFrame.new(0, angle * i, 0) * CFrame.new(0, 0, offsetFromPointHere) wait() end
I'm not sure if this is what you want |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:35 AM |
| I just did some testing with that program above and it doesn't rotate accordingly to the degrees. It always does a 180 no matter what I set the degrees to. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 12:36 AM |
| Is point.Position NOT part.Position? |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:36 AM |
| I meant the first one BTW sorry. |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:42 AM |
| What is the endlookvector? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 12:42 AM |
the start is the object's current lookVector the end is what you want it to be |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:49 AM |
Hmmmm? I did some more testing and all it did is move is to the other side of the point and then moved it on its y axis a few studs.
Here is what I have put: startLookVector = game.Workspace.Outer.CFrame.lookVector--outer is the object getting rotated endLookVector = Vector3.new(50,20,16)--a random spot for it to point at off = endLookVector-startLookVector angle = math.atan2(off.X, off.Z) + math.pi
for i = 0, 1, 0.1 do --a full rotation game.Workspace.Outer.CFrame = CFrame.new(game.Workspace.Center.Position) * CFrame.new(0, angle * i, 0) * CFrame.new(0, 0, 5)-- center is the point it gets rotated on wait() end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 12:50 AM |
endLookVector is supposed to be a unit vector. It's the end Direction. |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:54 AM |
so then the end vector should be?: endvector = (center.Position - newlookvector).unit |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 12:55 AM |
I already sort of did it for you, but it would be:
endLookVector = (newVector - centerPosition).unit |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 12:59 AM |
I really sorry to bug you so much but I'm having the same problem. :/ Here is my code:
startLookVector = game.Workspace.Outer.CFrame.lookVector endLookVector = (Vector3.new(50,20,16) - game.Workspace.Center.Position).unit off = endLookVector-startLookVector angle = math.atan2(off.X, off.Z) + math.pi
for i = 0, 1, 0.1 do --a full rotation game.Workspace.Outer.CFrame = CFrame.new(game.Workspace.Center.Position) * CFrame.new(0, angle * i, 0) * CFrame.new(0, 0, 5) wait() end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 01:01 AM |
No, you did it wrong. I meant to replace of |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 01:03 AM |
| What do you mean "I meant to replace of"? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 01:06 AM |
| Okay so you want to make an object's lookVector change to another lookVector? |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 01:09 AM |
| Well yes but the position of the object also needs to change. Another way of explaining it is like the moon orbiting Earth. So I need the moon to get as close as it can to the loovector with out going out of its radiuses from Earth. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 23 Dec 2013 01:10 AM |
"get as close as it can to the loovector" That's where I'm confused, it doesn't make sense, so you want: An object's front surface always facing a position while it's "revolving"? |
|
|
| Report Abuse |
|
|