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: Moving A Part With LookVector

Previous Thread :: Next Thread 
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
04 Jan 2012 11:56 PM
Yes I Googled this for awhile.
How can I move a part in the axis of another part with CFrame? That is what lookVector is for, correct?
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
04 Jan 2012 11:57 PM
"in the axis of another part with CFrame"
What do you mean by that?
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 12:00 AM
Move a part as if another part is the axis. The top of the block being up on the axis, ect..
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
05 Jan 2012 12:02 AM
Oh, so let's refer to them as Part1 and Part2. If Part1 is the object, and Part2 is the axis, then the direction Part2 is facing would be defined as the x axis?
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 12:07 AM
I know there's a way to do this that is really easy. That or I'm imagining things.

If the front and back of a part normally face the x axis when spawned, then yes.

Part2's faces would represent all of the axis. If Part2 was rotated 45 degrees on the y axis this would be the same as having the main axis rotated 45 degrees on the y axis for Part1.
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
05 Jan 2012 12:12 AM
Okay. Let's say that, for simplicity's sake, part2's lookVector is (1, 0, 1).
The x axis would be:
(1, 0, 1) where it would normally be (1, 0, 0).
So, add 1 to every z value (yeah right. I'm not sure about how to do this; I'm not good with CFrames). So:
Part.CFrame = Part.CFrame * CFrame.Angles(Part.Positon + Vector3.new(0, 0, 1)) to orient it the same way, I think? Then you can follow that logic. Sorry I'm not really more of a use. I don't even know if this will work.
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
05 Jan 2012 12:13 AM
Whoops. Why did I use Part.Position? Just use:
Vector3DirectionYouWant + Vector3.new(0, 0, 1)
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 12:21 AM
How would I go about sliding it on the axis of Part2?
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 07:25 PM
Bump, anyone please?
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 07:57 PM
Found the code finally...

Part.CFrame = Part.CFrame + (Part.CFrame.lookVector*5)
-- Moves Part along own axis.

I will modify this.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
05 Jan 2012 08:14 PM
> Move a part as if another part is the axis. The top of the block being up on the axis, ect..

If by that you mean as if that part is the origin, use `:toObjectSpace()`

    part0.CFrame=part1.CFrame:toObjectSpace(CFrame.new(0,0,5));
Report Abuse
Phrosty is not online. Phrosty
Joined: 04 Jan 2012
Total Posts: 346
05 Jan 2012 08:18 PM
Herm, I dun know.
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 08:26 PM
No not as origin. Treat it as if it's rotation was the workspace's.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
05 Jan 2012 08:27 PM
> No not as origin. Treat it as if it's rotation was the workspace's.

Exactly what I said...
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 08:31 PM
Oh sorry... I'm sick and in pain, focus is kinda hard.
What exactly does that do? It makes parts move to a "random" spot for me.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Jan 2012 08:34 PM
You can use Vector3.FromNormalId() to get the unit vector of a surface. Then multiply this by x. x is the number of studs away from the part.

pos = Vector3.FromNormalId(Enum.NormalId.Top) * 10

Will give you the position 10 studs above the top surface.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
05 Jan 2012 08:34 PM
It makes it as if Part0's CFrame is the identity.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Jan 2012 08:34 PM
Oops, I forgot to mention you also have to add the original position.
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 08:54 PM
@SDuke:
That just throws it a "Random" place no matter what I try.

@Blockoo:
In the command bar...
Part1.CFrame=Part1.CFrame+Part2.FromNormalId(Enum.NormalId.Top) * 10
Gives...
Part1=workspace.Part1 Part2=workspace.Part2 Part1.CFrame=Pa:1: attempt to call global 'Part2' (a userdata value)
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Jan 2012 08:56 PM
Part1.CFrame = CFrame.new(Part1.Position + Vector3.FromNormalId(Enum.NormalId.Top) * 10)
Report Abuse
SwiftWolf is not online. SwiftWolf
Joined: 04 Aug 2008
Total Posts: 1140
05 Jan 2012 09:00 PM
How would I change the axis to that of another part?
I don't know how to code CFrame well.
Report Abuse
xvgigakid is not online. xvgigakid
Joined: 22 Jun 2008
Total Posts: 4407
05 Jan 2012 09:08 PM
@Swift
You could do this

Object.CFrame = Object2.CFrame*CFrame.new(x,y,z)
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
05 Jan 2012 09:10 PM
This is the same problem I had. -__-
Report Abuse
xvgigakid is not online. xvgigakid
Joined: 22 Jun 2008
Total Posts: 4407
05 Jan 2012 09:14 PM
'Part1.CFrame = CFrame.new(Part1.Position + Vector3.FromNormalId(Enum.NormalId.Top) * 10)'

I really dont see why you guys are trying to figure this out the hard way when its so simple :/
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Jan 2012 09:14 PM
Another method (not tested):

part.CFrame = part.CFrame:toWorldSpace(part.CFrame:toObjectSpace(part.CFrame) + Vector3.new(0, 10, 0))
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