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 » Scripters
Home Search
 

Re: Making a part look in the same direction as the other.

Previous Thread :: Next Thread 
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Jan 2015 10:17 PM
This doesn't make a lot of sense really.. As when testing with regular parts the rotation turns the wanted way. However here it isn't working.

What I tried in CommandBar:
Workspace.p2.CFrame = CFrame.new(Workspace.p2.CFrame.p, Workspace.Part.CFrame.lookVector * 10000)

What's not working;

local dif = plane.PrimaryPart.Position-player.Character.Torso.Position
plane.Name, plane.Parent = player.Name..": Plane", Workspace;
plane:SetPrimaryPartCFrame(plane.PrimaryPart.CFrame + dif);
plane:SetPrimaryPartCFrame(CFrame.new(plane.PrimaryPart.CFrame.p, player.Character.Torso.CFrame.lookVector * 1000));
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
21 Jan 2015 10:19 PM
'plane.PrimaryPart.CFrame + dif)'

I assume you mean (plane.PrimaryPart.CFrame).p?


::_::goto_
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Jan 2015 10:20 PM
No.
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
21 Jan 2015 10:22 PM
Have you set the PrimaryPart?


::_::goto_
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Jan 2015 10:24 PM
Of course.
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
21 Jan 2015 10:25 PM
Hold on, you can use math on two separate datatypes within Lua?
I wasn't aware you could add a Vector3 to a CFrame.

Learn something everyday I guess.


::_::goto_
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Jan 2015 10:27 PM
It is right in the wiki article....
http://wiki.roblox.com/index.php?title=CFrame#Operators
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
21 Jan 2015 10:35 PM
I'm not sure I understand why you would do this:

"plane:SetPrimaryPartCFrame(plane.PrimaryPart.CFrame + dif);"
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Jan 2015 10:37 PM
To move the plane to the Torso's position without losing orientation?
Report Abuse
cxcharlie is not online. cxcharlie
Joined: 26 Aug 2009
Total Posts: 1414
21 Jan 2015 10:44 PM
You could just get the rotational matrix of the other part using "components()"

local _ ,__ ,___ , R00, R01, R02, R10, R11, R12, R20, R21, R22 = part.CFrame:components()
local x,y,z = part2.Position.X,part2.Position.Y,part2.Position.Z
part2.CFrame = CFrame.new(x , y, z,R00, R01, R02, R10, R11, R12, R20, R21, R22)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
21 Jan 2015 10:46 PM
Why you not just do this

Workspace.p2.CFrame = CFrame.new(Workspace.p2.CFrame.p, Workspace.p2.CFrame.p + Workspace.Part.CFrame.lookVector)
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Jan 2015 11:02 PM
Whilst that does work. I should add I need to rotate it on the back and right axis only.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
21 Jan 2015 11:09 PM
Just extract the X and Z from the lookVector alone then?
Something like this should work:

local look = Workspace.Part.CFrame.lookVector;
local dir = Vector3.new(look.X, 0, look.Z);
Workspace.p2.CFrame = CFrame.new(Workspace.p2.CFrame.p, Workspace.p2.CFrame.p + dir)
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
21 Jan 2015 11:39 PM
I ended up having to use the rotation matrix as it didn't give the desired result. Thanks for the help however.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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