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
 

Moving object 'forwards'

Previous Thread :: Next Thread 
Opisek is not online. 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 is not online. Opisek
Joined: 05 Aug 2014
Total Posts: 155
20 Apr 2016 06:51 AM
Bump
Report Abuse
Unravaled is not online. 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 is not online. 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 is not online. 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 is not online. 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
vectorGunner is not online. vectorGunner
Joined: 23 Mar 2014
Total Posts: 784
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 is not online. 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
vectorGunner is not online. vectorGunner
Joined: 23 Mar 2014
Total Posts: 784
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
LeftShaark is not online. LeftShaark
Joined: 13 Apr 2013
Total Posts: 40
20 Apr 2016 09:15 AM
aaaaaa


Report Abuse
Opisek is not online. 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
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
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
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