|
| 28 Feb 2015 09:48 PM |
Hey! So I was trying to make a door rotate with CFrame to make it look like it has hinges but I was wondering, is there an easier way to set the rotation point at the doors imaginary hinges? Here's my script so far that took some time to adjust because of this problem.
door.CFrame = door.CFrame * CFrame.new(0,0,0.001) * CFrame.Angles(0,math.rad(80),0)
This would work but is there an easier way to set the rotation point to the hinges of the door if let's say the door's size is (10,10,1) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 28 Feb 2015 10:22 PM |
| I can't, because the door is anchored. Also this is just an experiment with CFraming. :p |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 10:57 PM |
Unanchor the door. Use a weld. Yes. :D
Or, if you want it on THAT point...
Point = CFrame.new(0, 10, 0) Angle = 0 Door = PleaseSupplySufficientDoorHere,Thanks.:)
for x = 1, 30 do Angle = Angle + math.rad(3) Door.CFrame = Point * CFrame.Angles(0, Angle, 0) * CFrame.new(Door.Size.X / 2, 0, 0) wait() end
Something like that? :D |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 11:23 PM |
| I think so but I already tried the method of dividing X's size yet the point of rotation is way off and the part just circles around the map. I think that CFrame needs to be very small. Anyone know maybe an equation that can get this number to change the point of rotation to the last stud/tip of the door part? |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 11:29 PM |
I tried the script, it worked fine. Problem? |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 11:31 PM |
| It does work, just not properly, because instead of setting the point of rotation at the "hinges" of the door, it sets the point of rotation like 50 studs off. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 11:32 PM |
| Also for a part that is like 10 studs, it would need to be like (0.02,0,0) to make it work properly. Is there any way I can get that directly depending on the parts X size? |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:43 PM |
| Anyone know? :/ I've had this issue for some time. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 08:00 PM |
Simple math :)
local increment = .05 -- best to keep it to a 5-base of 1(0)-base increment
function RunAnimation(p) local p = p or script.Parent local rightframe = p.CFrame + p.CFrame:vectorToWorldSpace( Vector3.new(1,0,0) * p.Size.X/2 ) for i = 0, math.pi/2, .05 do wait() local newframe = rightframe * (CFrame.Angles(0, -i, 0) * CFrame.new(p.Size.X/-2,0,0)) p.CFrame = newframe end end
RunAnimation() |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 10:12 PM |
| Ah ok thanks! But it looks sort of complex :/ What exactly does vectorToWorldSpace do? :o |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 10:13 PM |
In this instance, :vectorToWorldSpace gets the world-space vector in relation to the object-space vector I gave it.
Basically, I use it to find out what direction the right-surface faces.
In object-space, Vector3.new(1,0,0) is 1 stud to the right of the object. So I turn it into world-space to find out where the right direction is facing in the world. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 10:36 PM |
| Oh I think I get it! So basically toWorldSpace finds out the facing direction of an object's side? |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 10:40 PM |
I guess.
Imagine it as if the thing inside the parenthesis of :vectorToWorldSpace was in relation to the CFrame of the part before the colon (:).
So...
Vector3.new(1,0,0)
Pretend that is actually
Part.CFrame + Vector3.new(1,0,0)
I'm just turning that into world-space.
Actually.... forget it. Screw that explanation.
Yeah, it can get the direction of an object's side. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 10:44 PM |
| Ah ok! Thank you very much, I think I get it finally! And toObjectSpace does the opposite of toWorldSpace. :D |
|
|
| Report Abuse |
|
|