How to Make Ramps: Difference between revisions
>Tomtomn00 |
>Jopc67 Syntax Highlighting |
||
Line 34: | Line 34: | ||
Make a brick, anchor it and name it "slope". Then open the [[Scripting#Fundamentals|Command Bar]] and type this in: | Make a brick, anchor it and name it "slope". Then open the [[Scripting#Fundamentals|Command Bar]] and type this in: | ||
< | <code lua> | ||
s = game.Workspace.slope; s.CFrame = CFrame.Angles(0,0,0) + s.CFrame.p | s = game.Workspace.slope; s.CFrame = CFrame.Angles(0,0,0) + s.CFrame.p | ||
</ | </code> | ||
Change the "(0,0,0)" to how many [http://en.wikipedia.org/wiki/Radian radians] (not degrees) you want it to rotate. Instead of using [http://en.wikipedia.org/wiki/Degree_%28angle%29 degrees], they use radians, which are a different way of saying how big an angle is. | Change the "(0,0,0)" to how many [http://en.wikipedia.org/wiki/Radian radians] (not degrees) you want it to rotate. Instead of using [http://en.wikipedia.org/wiki/Degree_%28angle%29 degrees], they use radians, which are a different way of saying how big an angle is. | ||
Line 42: | Line 42: | ||
Play around with it, you can put the new number in either one of the three zeroes in the line, like this: | Play around with it, you can put the new number in either one of the three zeroes in the line, like this: | ||
< | <code lua> | ||
s = game.Workspace.slope; s.CFrame = CFrame.Angles(math.rad(30), math.rad(45), 0) + s.CFrame.p | s = game.Workspace.slope; s.CFrame = CFrame.Angles(math.rad(30), math.rad(45), 0) + s.CFrame.p | ||
</ | </code> | ||
Which will make it rotate in all kinds of directions. | Which will make it rotate in all kinds of directions. | ||
Also, you can use | Also, you can use | ||
< | <code lua> | ||
s = game.Workspace.slope; s.CFrame = CFrame.fromAxisAngle(Vector3.new(0,0,1), math.pi/2) + s.CFrame.p | s = game.Workspace.slope; s.CFrame = CFrame.fromAxisAngle(Vector3.new(0,0,1), math.pi/2) + s.CFrame.p | ||
</ | </code> | ||
* Change the <code>Vector3.new(0,0,1)</code> to the line to rotate around. For example, if you want to rotate the brick around the z axis, use <code>Vector3.new(0,0,1)</code>. If you want to rotate the brick around the y axis, use <code>Vector3.new(0,1,0)</code>. If you want to rotate the brick around the x = z line, use <code>Vector3.new(1,0,1)</code>. | * Change the <code lua>Vector3.new(0,0,1)</code> to the line to rotate around. For example, if you want to rotate the brick around the z axis, use <code lua>Vector3.new(0,0,1)</code>. If you want to rotate the brick around the y axis, use <code lua>Vector3.new(0,1,0)</code>. If you want to rotate the brick around the x = z line, use <code lua>Vector3.new(1,0,1)</code>. | ||
* Lastly, change math.pi/2 to the value in radians you wish to angle the brick by. This can be a constant, a variable, up to you. | * Lastly, change math.pi/2 to the value in radians you wish to angle the brick by. This can be a constant, a variable, up to you. | ||
Revision as of 04:41, 4 January 2012
Introduction
There are three ways you can make ramps. You can either use a Hinge or a CFrame to edit rotation, or you can simply insert a WedgePart
Using a Hinge
- In Roblox studio, click Workspace.
- Click Insert > Object > Part
- Resize the newly brick so that it is one unit wide, one unit long, and as tall as you want.
- Click the Weld option in your Toolbar (it has an X in a square).
- Click ONE side of your tall brick with the weld option.
- Click Workspace.
- Click Insert > Object > Part
- Resize this newly created brick so it is one unit wide, one unit long, and one unit tall.
- Click the Weld option in your Toolbar.
- Click the side of this brick that is facing the welded side of the TALL brick with the weld option. You should have two welded faces facing each other.
- Select the Drag option in your Toolbar.
- Place the small brick near the top of the tall tower.
- Select the Hinge option on your Toolbar
- Click the small brick. A yellow dot should be protruding from it.
- Click Workspace.
- Click Insert > Object > Part
- Resize this newly created brick to a long, flat, rectangle.
- Drag this newly created rectangle so that you can't see the yellow dot.
- Test your game. If you did this correctly, your bar should fall downwards.
Using a CFrame
Make a brick, anchor it and name it "slope". Then open the Command Bar and type this in:
s = game.Workspace.slope; s.CFrame = CFrame.Angles(0,0,0) + s.CFrame.p
Change the "(0,0,0)" to how many radians (not degrees) you want it to rotate. Instead of using degrees, they use radians, which are a different way of saying how big an angle is.
Play around with it, you can put the new number in either one of the three zeroes in the line, like this:
s = game.Workspace.slope; s.CFrame = CFrame.Angles(math.rad(30), math.rad(45), 0) + s.CFrame.p
Which will make it rotate in all kinds of directions.
Also, you can use
s = game.Workspace.slope; s.CFrame = CFrame.fromAxisAngle(Vector3.new(0,0,1), math.pi/2) + s.CFrame.p
- Change the
Vector3.new(0,0,1)
to the line to rotate around. For example, if you want to rotate the brick around the z axis, useVector3.new(0,0,1)
. If you want to rotate the brick around the y axis, useVector3.new(0,1,0)
. If you want to rotate the brick around the x = z line, useVector3.new(1,0,1)
. - Lastly, change math.pi/2 to the value in radians you wish to angle the brick by. This can be a constant, a variable, up to you.
Using a WedgePart
- In Roblox studio, click Workspace.
- Click Insert > Object > WedgePart
- It's as simple as that. You now have a WedgePart that acts like a ramp.