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: CFraming a door to open from a hinge

Previous Thread :: Next Thread 
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
16 Nov 2014 08:22 PM
I want to make a door that opens like it would like a regular door, from a hinge. But, I want to cframe it. How would I do something like this? (I'm not referring to sliding door, I'm talking about what a door does in real life when you open it)
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
16 Nov 2014 08:30 PM
bump for the night
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
16 Nov 2014 08:57 PM
CFrame.new(HingePosition) * CFrame.Angles(0, math.rad(HingeAnglesInDegrees),0) * CFrame.new(0, 0, -Door.Size.Z/2)
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
17 Nov 2014 05:46 AM
Well thats complex
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Nov 2014 05:51 AM
Well I thought you wanted that...

The first part sets the CFrame at the hinge. The second rotates it, and the third moves the door outwards.
Report Abuse
Mkhero4433 is not online. Mkhero4433
Joined: 28 Aug 2010
Total Posts: 227
17 Nov 2014 05:59 AM
I found it more simplier Metaphorically of course

Assuming Door is classified

function tehdoor()
for i = 1,90 do
Door.CFrame = Door.CFrame *CFrame.Angles(0,0,.1)
wait()
end
for i = 1,90 do
Door.CFrame = Door.CFrame *CFrame.Angles(0,0,-.1)-- Just opposite
wait()
end

Door.Touched:connect(tehdoor)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Nov 2014 06:02 AM
But that doesn't rotate it on it's hinge, unless it's hing is in the middle.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
17 Nov 2014 06:03 AM
Then add a Part next to it which enholds dem hinges e.e
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Nov 2014 06:09 AM
But then it would break off, if you mean the joint kind.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
17 Nov 2014 07:45 AM
Weld them
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
17 Nov 2014 07:45 AM
What you want is a "swing on axis" method. Here's code I wrote for Justin Kennett when he needed the same thing.

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()

It causes the door to open on its positive X axis end like a real door does.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
17 Nov 2014 07:49 AM
Does it automatically close? ;3
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