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 » Scripters
Home Search
 

Re: CFrame door rotation

Previous Thread :: Next Thread 
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
28 Feb 2015 10:19 PM
Does anyone know how?
Report Abuse
HelpfulToasty is not online. HelpfulToasty
Joined: 20 Dec 2013
Total Posts: 152
28 Feb 2015 10:21 PM
Use a weld.
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
HelpfulToasty is not online. HelpfulToasty
Joined: 20 Dec 2013
Total Posts: 152
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
HelpfulToasty is not online. HelpfulToasty
Joined: 20 Dec 2013
Total Posts: 152
28 Feb 2015 11:29 PM
I tried the script, it worked fine.
Problem?
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
01 Mar 2015 07:43 PM
Anyone know? :/ I've had this issue for some time.
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
01 Mar 2015 10:12 PM
Ah ok thanks! But it looks sort of complex :/ What exactly does vectorToWorldSpace do? :o
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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