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 |
|
|
|
| 04 Jan 2012 11:57 PM |
"in the axis of another part with CFrame" What do you mean by that? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 05 Jan 2012 12:13 AM |
Whoops. Why did I use Part.Position? Just use: Vector3DirectionYouWant + Vector3.new(0, 0, 1) |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 04 Aug 2008 |
| Total Posts: 1140 |
|
| |
|
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
|
  |
| 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
|
  |
| Joined: 04 Jan 2012 |
| Total Posts: 346 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 05 Jan 2012 09:10 PM |
| This is the same problem I had. -__- |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|