sheepsies
|
  |
| Joined: 02 May 2011 |
| Total Posts: 6653 |
|
| |
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 24 Aug 2014 01:38 PM |
@oats That only works for unanchored objects. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|