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: how do i pivot an object around a point?

Previous Thread :: Next Thread 
sheepsies is not online. sheepsies
Joined: 02 May 2011
Total Posts: 6653
24 Aug 2014 01:16 PM
ehm?
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Aug 2014 01:17 PM
Elaborate, please?
Report Abuse
sheepsies is not online. sheepsies
Joined: 02 May 2011
Total Posts: 6653
24 Aug 2014 01:19 PM
using a script, how would i pivot an object around a specific point.
basically like a door, except scripted.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Aug 2014 01:25 PM
Well, first you have to generate a phony CFrame to act as the pivot point. Then you need to position the door using relative object coordinates. Here's an example (the variables at the top remain constant):

pivot = CFrame.new(x, y, z)
relativeCF = door.CFrame:toObjectSpace(pivot)

function rotate()
pivot = pivot * CFrame.Angles(x, y, z)
door.CFrame = relativeCF:toWorldSpace(pivot)
end
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
24 Aug 2014 01:30 PM
I think you'd use a Motor6D?

Here's the wiki page for it:
http://wiki.roblox.com/index.php?title=API:Class/Motor6D

and I was recommended this thread as a good explanation on welds:
http://www.roblox.com/Forum/ShowPost.aspx?PostID=59544478

I haven't started working with welds so I can't really help you much further than that.
Report Abuse
sheepsies is not online. sheepsies
Joined: 02 May 2011
Total Posts: 6653
24 Aug 2014 01:36 PM
Thank you so much, but I managed to code it myself.
It's a terribly messy script but it worked, and though it may not be as good as some of these I feel as if I personally created it.


Thanks anyway though, mates.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
24 Aug 2014 01:38 PM
@oats
That only works for unanchored objects.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
24 Aug 2014 11:21 PM
Ah alright, gotcha blockoo.

Your solution with the "phony" CFrame is actually quite brilliant with its simplicity. I would not have come up with that on my own.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
24 Aug 2014 11:36 PM
@blockoo

I was trying to work out how your method works out mathematically, and it didn't really seem to line up properly in my head so I decided to test it out and it didn't work. Are you sure your method works?
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
25 Aug 2014 01:11 PM
My mistake, I flipped the values for toWorldSpace by mistake. This should work:

pivot = CFrame.new(x, y, z)
relativeCF = door.CFrame:toObjectSpace(pivot)

function rotate()
pivot = pivot * CFrame.Angles(x, y, z)
door.CFrame = pivot:toWorldSpace(relativeCF)
end

However, I don't understand why but depending on the rotation of the door, the door likes to do strange things, like orbit around the axis instead of pivoting on it. It makes no sense, and I'm pretty sure it shouldn't be doing that.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
25 Aug 2014 02:20 PM
Ah! I thought something was a bit off.

I tried it now and it works, but you have to do:

door.CFrame = pivot:toWorldSpace(relativeCF:inverse())

If you don't use the inverse, then the door will rotate the proper angle, but flip over to the other side of the pivot.
Thanks blockoo
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