Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[=[
- To see this in action, in your games console do `require(837243090):Init();`
- _____KEY_______
- * = brick in center of rectangle [Width is X Axis]
- [ ]
- ________ [Depth is Z Axis]
- | | [_______________]
- | | Depth = 7
- | |
- | * |
- | |
- | | brick.Position = (0,0,0) ---current position of our brick
- |________| brick.Size = (4,0,4) -------the current size of our brick
- --------
- Width = 8
- To get to one side, we must add the width of the rectangle divided by 2 to the
- position of our brick. Like so:
- brick.Position = brick.Position + Vector3.new(rectangle.Size.X/2,0,0)
- Which will put our brick on the right look:
- ________
- | |
- | |
- | |
- | *|
- | |
- | | brick.Position = (4,0,0) ---current position of our brick
- |________|
- Subtracting will have the opposite effect and put it on the left. Now how do we get
- to the corner? Well we add half of the depth to our bricks position Like so:
- brick.Position = brick.Position + Vector3.new(0,0,rectangle.Size.Z/2)
- This would put the brick at the top right corner, If you want to put the brick insde the
- rectangle then you must subtract half of the brick size like so:
- brick.Position=brick.Position+Vector3.new(0,0,((rectangle.Size.Z/2)-(brick.size.Z/2)))
- --------------------------------random position inside the brick:-------------------------------
- To get a random position inside the rectangle create a function that will math.random the size
- of the part, the part is where the lightning will emit from. Once that is done return the
- random number as a vector3 (You would of course do this for both X and Z). Imagine i am
- saving what the random function returned into the variable called `randPos`, now do this to
- place it at a random pos in the obj:
- part.Position = Rectangle.Position+(Vector3.new(((randPos.X-Rectangle.Size.X)+(Rectangle.Size.X/2)),0,((randPos.Z-Rectangle.Size.Z)+(Rectangle.Size.Z/2)))-Vector3.new(0,part.Size.Y/2,0))
- --]=]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement