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 » Scripting Helpers
Home Search
 

Re: Rotating a object around a point?

Previous Thread :: Next Thread 
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
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
PiggyJingles is not online. PiggyJingles
Joined: 13 Jan 2009
Total Posts: 2472
22 Dec 2013 11:56 PM
Use circumference :3
Report Abuse
cntkillme is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
23 Dec 2013 12:09 AM
I want the object to move around a point like a compass.
Report Abuse
cntkillme is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
23 Dec 2013 12:18 AM
That just rotates the object I'm talking about a compass that draws circles.
Report Abuse
cntkillme is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
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 is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Dec 2013 12:36 AM
Is point.Position NOT part.Position?
Report Abuse
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
23 Dec 2013 12:36 AM
I meant the first one BTW sorry.
Report Abuse
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
23 Dec 2013 12:42 AM
What is the endlookvector?
Report Abuse
cntkillme is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
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 is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
23 Dec 2013 12:54 AM
so then the end vector should be?:
endvector = (center.Position - newlookvector).unit
Report Abuse
cntkillme is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
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 is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
23 Dec 2013 01:03 AM
What do you mean "I meant to replace of"?
Report Abuse
cntkillme is not online. 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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
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
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
23 Dec 2013 01:10 AM
radius*
lookvector*
Report Abuse
cntkillme is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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