|
| 11 Aug 2012 12:48 PM |
I can't seem to get my math quite right. I'm currently generating 4 parts in a square and having the main object - test - tween to each part in the square, while facing the direction of the following part. Here's the code if I made that too confusing
------------------------------------------------------------- local test = Workspace.Test local parts = {}
--Generate Parts in a square for i, pos in ipairs({Vector3.new(15, 0, 0), Vector3.new(-15, 0, 0), Vector3.new(-15, 0, 15), Vector3.new(15, 0, 15)}) do
parts[i] = Instance.new("Part", Workspace) parts[i].Anchored = true parts[i].CFrame = test.CFrame + pos
end
for i = 1, 5 do local p1 = parts[((i-1)%4)+1] local p2 = parts[(i%4)+1]
local cf = CFrame.new(p1.Position, p2.Position) local angles = Vector3.new(cf:toEulerAnglesXYZ()) local newCF = CFrame.Angles(0, angles.y, 0)+cf.p
tweenTo(test, newCF, true, 5) end -------------------------------------------------------------
tweenTo is just the tweening function I'm using. Anyways my problem is when its tweening from parts[1] to parts[2](second loop). In that loop the angles is (math.pi, 0, math.pi) but when I include the x and z axes the part starts tilting mid-tween. When I exclude the x and z the part tweens fine but I can't get it to face the right direction, ie - It faces foward instead of backward. Is there any way to fix this? |
|
|
| Report Abuse |
|
| |
|
| 11 Aug 2012 01:36 PM |
bump? sorry don't know *le exact math your looking for. use *le calculator? |
|
|
| Report Abuse |
|
|
| 11 Aug 2012 01:43 PM |
"le exact math your looking for. use *le calculator? "
uhh not exactly last paragraph |
|
|
| Report Abuse |
|
| |
| |
| |
| |