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
 

Help with math

Previous Thread :: Next Thread 
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
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
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
11 Aug 2012 01:15 PM
bump
Report Abuse
TheAmazingMacintosh is not online. TheAmazingMacintosh
Joined: 15 Jan 2012
Total Posts: 196
11 Aug 2012 01:36 PM
bump?
sorry don't know *le exact math your looking for. use *le calculator?
Report Abuse
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
11 Aug 2012 01:43 PM
"le exact math your looking for. use *le calculator? "

uhh not exactly
last paragraph
Report Abuse
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
11 Aug 2012 02:12 PM
bump
Report Abuse
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
11 Aug 2012 05:09 PM
bump
Report Abuse
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
11 Aug 2012 06:31 PM
bump
Report Abuse
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
11 Aug 2012 07:10 PM
bump
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