Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 06:33 AM |
| Hi! I need to make door that slides on its side. Yeah, it's very easy, but what if I rotate the door? It won't work anymore right? It's would take a long time to make a script that moves object using its angle with sin and cos. It's not even that hard, but takes a long time. Is it possible to do it easier? Thanks for your help! |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
| |
|
Unravaled
|
  |
| Joined: 18 Jul 2011 |
| Total Posts: 1117 |
|
|
| 20 Apr 2016 07:24 AM |
Use CFrame instead of Vector3 if you want it to work properly even if rotated
Or lookvector if you want.
|
|
|
| Report Abuse |
|
|
Unravaled
|
  |
| Joined: 18 Jul 2011 |
| Total Posts: 1117 |
|
|
| 20 Apr 2016 07:25 AM |
http://wiki.roblox.com/index.php?title=CFrame
|
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 08:03 AM |
| I actually use CFrame, but I didn't know if it'll work. Thanks for your answer! |
|
|
| Report Abuse |
|
|
Auzer
|
  |
| Joined: 24 Dec 2011 |
| Total Posts: 1590 |
|
|
| 20 Apr 2016 08:07 AM |
Part.CFrame = Part.CFrame * CFrame.new(1, 0, 0)
Moves the part one stud on the X axis even though rotated. |
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 08:14 AM |
So you're asking for rotating doors?
Create a model of a door with an invisible primary part. This will be the hinge, position it where the doors hinge would be. Now to open the door simply rotate the models primary part with CFrame.Angles() |
|
|
| Report Abuse |
|
|
Unravaled
|
  |
| Joined: 18 Jul 2011 |
| Total Posts: 1117 |
|
|
| 20 Apr 2016 08:24 AM |
Vector don't reply if you don't understand what they want to know.
|
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 08:25 AM |
Oh yeah, my bad. Let me be as helpful as you.
http://wiki.roblox.com/index.php?title=CFrame |
|
|
| Report Abuse |
|
|
| |
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 09:17 AM |
| Already saw that :) Thanks everyone, I just wanted to ask you before I make script and will be in need to change everything. So thanks for answering, it's just like i tought it is. |
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 09:44 AM |
CFrame * CFrame makes a CFrame translated (moved) relative to the first CFrame.
So if you do thing.CFrame = thing.CFrame * CFrame.new(0, 0, -1), then that thing will be moved 1 stud forward, regardless of how it is rotated.
0, 1, 0 is up, 0, 0, 1 is backwards, 1, 0, 0 is left or right, I don't remember
You can also use enums, like this:
function movePartInDirection(part, direction, amount) assert(type(direction) == "String", "direction should be a string") --You could do this shorter. It just do it like this to illustrate the point, mkay? local normalId = Enum.NormalId[direction] local vectorDirection = Vector3.fromNormalId(normalId) local cfDirection = CFrame.new() + vectorDirection * amount
part.CFrame = part.CFrame * cfDirection end |
|
|
| Report Abuse |
|
|