gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 29 Oct 2012 06:09 PM |
I'm stuck. I've been trying to rotate and move a brick at the same time...
local bin = script.Parent
local binorig = bin.Position
local bin1 = bin.CFrame
for i=0, 9, .1 do bin.CFrame = bin1+Vector3.new(i/2,0,0) bin.CFrame = bin.CFrame+Vector3.new(i/2,0,i) wait() end
for i = 0, math.pi/2, math.pi/100 do local binorig1 = bin.Position local orig = bin.CFrame + Vector3.new(i,0,i*7) bin.CFrame = orig+Vector3.new(10*math.sin(i), 0, 10*math.cos(i)) bin.CFrame = CFrame.new(binorig1, bin.Position) wait() end
Trying to combine the 2 for loops into one, that will rotate and move the brick at the same time. |
|
|
| Report Abuse |
|
|
gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 29 Oct 2012 06:28 PM |
| I think I could do it if I understood CFrame values better. |
|
|
| Report Abuse |
|
|
|
| 29 Oct 2012 06:29 PM |
Variables are messed up
local bin = script.Parent
for i=0, 9, .1 do bin.CFrame = bin.CFrame1+Vector3.new(i/2,0,0) bin.CFrame = bin.CFrame+Vector3.new(i/2,0,i) wait() end
for i = 0, math.pi/2, math.pi/100 do local binorig1 = bin.Position local orig = bin.CFrame + Vector3.new(i,0,i*7) bin.CFrame = orig.Position+Vector3.new(10*math.sin(i), 0, 10*math.cos(i)) bin.Position = Vector3.new(bin.Position) --bin.Position, bin.Position? wait() end
|
|
|
| Report Abuse |
|
|
|
| 29 Oct 2012 06:30 PM |
oops try this
local bin = script.Parent
for i=0, 9, .1 do bin.CFrame = bin.CFrame1+Vector3.new(i/2,0,0) bin.CFrame = bin.CFrame+Vector3.new(i/2,0,i) wait() end
for i = 0, math.pi/2, math.pi/100 do local orig = bin.CFrame + CFrame.new(i,0,i*7) --can't mix CFrame and Vector3 values bin.CFrame = orig.Position+Vector3.new(10*math.sin(i), 0, 10*math.cos(i)) bin.Position = Vector3.new(bin.Position) --bin.Position, bin.Position? wait() end
what are you trying to do here? |
|
|
| Report Abuse |
|
|
gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 29 Oct 2012 06:36 PM |
| You see how the first for loop moves the brick and the second one rotates? I'm trying to get one for loop to do both, so the brick moves and rotates at the same time. |
|
|
| Report Abuse |
|
|
gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 29 Oct 2012 06:55 PM |
local bin = script.Parent local binorig = bin.CFrame
for i=0, 9, .1 do bin.CFrame = binorig + Vector3.new(i/2,0,i) wait() end
This part (I changed a bit) moves the brick from its starting position at a constant rate.
The rest...gets more and more confusing. |
|
|
| Report Abuse |
|
|
|
| 29 Oct 2012 08:00 PM |
| Again, you can't compare CFrame with Vector3. |
|
|
| Report Abuse |
|
|
gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 30 Oct 2012 04:52 PM |
Now I'm starting to think I need to use Euler Angles...
CFrame.new(x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22)
And change that around. |
|
|
| Report Abuse |
|
|
jjone12
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 79 |
|
|
| 30 Oct 2012 06:22 PM |
| You cant try and use Vector3, and CFrame. Its litterally Impossible, and EXTREEMLY COMPLCATED. Originally yoru variables were messed up throughout the entire thing. |
|
|
| Report Abuse |
|
|
jjone12
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 79 |
|
|
| 30 Oct 2012 06:24 PM |
| I meant mix. Im sorry. But you are on the right track with EulerAngles, but a lot of work is to be done. |
|
|
| Report Abuse |
|
|
gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 30 Oct 2012 10:07 PM |
| Fantastic. Now just to figure out the matrix. |
|
|
| Report Abuse |
|
|
jjone12
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 79 |
|
| |
|
gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 31 Oct 2012 06:29 PM |
| I think I get the general idea of setting what the axis are that the part rotates on, then setting the amount the rotation is on each axis. The specifics though... |
|
|
| Report Abuse |
|
|
gbs
|
  |
| Joined: 10 Apr 2008 |
| Total Posts: 16823 |
|
|
| 31 Oct 2012 08:55 PM |
Progress made: I can now move and rotate the brick at the same time. However, moving and rotating the brick back to it's starting position is...not working.
The first for loop moves and rotates for awhile; the second should take the values at the end of the fist loop and reverse the movement. I'm not sure why, but m20 is not enough to save the rotation of the brick for use in the second loop (basically, large jump because rotation is set to something different).
You may want to see the script in action in game to see what I'm talking about.
local bin = script.Parent local c = bin.CFrame.x local d = bin.CFrame.y local e = bin.CFrame.z
for i=0.0000001, .9, .001 do bin.CFrame = CFrame.new(c+i*10, d, e+i*6.5, 1, -0, -0, -0, 1, -0, -i, 0, 1) wait() end
local a = bin.CFrame.x local b = bin.CFrame.z local sx, sy, sz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = bin.CFrame:components()
for i=0.0000001, .9, .001 do bin.CFrame = CFrame.new(a-i*10, d, b-i*6.5, 1, -0, m02-i, -0, 1, -0, m20+i, 0, 1) wait() end |
|
|
| Report Abuse |
|
|