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: how to get a part to face the lookvector of another part?

Previous Thread :: Next Thread 
Lord_Oscar is not online. Lord_Oscar
Joined: 15 Nov 2009
Total Posts: 17662
08 May 2016 11:42 AM
is it just CFrame.new(1,1,1) * CFrame.Angles(0,0,math.rad(script.Parent.CFrame.lookVector))

?


It's simple physics
Report Abuse
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
08 May 2016 11:53 AM
lookVector is an XYZ value, not a single number. You should try something with the rotation matrix.

local part = game.Workspace.Part
local otherPart = script.Parent.CFrame:components()
--Not totally sure how to do this, but this is my best guess.
part.CFrame = CFrame.new(otherPart)-Vector3.new(1,1,1) --Pretty sure this keeps rotation of otherPart but not position.

Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 May 2016 11:56 AM
Extreme, you can't use the CFrame.new constructor like that can you? Only with a Vector3 value or Vector3 value + quaternion?



~~~Da siggy is OP~~~
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 May 2016 11:56 AM
Never mind, read the wiki.


~~~Da siggy is OP~~~
Report Abuse
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
08 May 2016 12:01 PM
I just tested it out, it's expecting a vector3 for some reason, have I misunderstood components()?
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 May 2016 12:04 PM
Can't you just do :


local part = game.Workspace.Part
local otherPartCFrame = script.Parent.CFrame
part.CFrame = otherPartCFrame-Vector3.new(1,1,1)


~~~Da siggy is OP~~~
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 May 2016 12:08 PM
local part = game.Workspace.Part
local otherPartRotation = script.Parent.CFrame.lookVector
part.CFrame = CFrame.new(part.Position) * CFrame.Angles(otherPartRotation)


~~~Da siggy is OP~~~
Report Abuse
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
08 May 2016 12:09 PM
@Rock yup...I overcomplicated things ;(
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 May 2016 12:10 PM
Or,

local part = game.Workspace.Part
local otherPartRotation = script.Parent.CFrame.lookVector
part.CFrame = CFrame.new(part.Position) * CFrame.Angles(math.rad(otherPartRotation.X),math.rad(otherPartRotation.Y),math.rad(otherPartRotation.Z))


~~~Da siggy is OP~~~


~~~Da siggy is OP~~~
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 May 2016 12:11 PM
Ye, it's fine Extreme. I think my last script will work Lord_Oscar, try that.


~~~Da siggy is OP~~~
Report Abuse
Lord_Oscar is not online. Lord_Oscar
Joined: 15 Nov 2009
Total Posts: 17662
08 May 2016 12:13 PM
I actually figured out a completely different work around that works better. Thanks though!


It's simple physics
Report Abuse
KapKing47 is not online. KapKing47
Joined: 09 Sep 2012
Total Posts: 5522
08 May 2016 12:17 PM
local dir = Vector3.new(0, 1, 0) --Assuming it's the top of the part, if not change the axes
local cf = CFrame.new(Part.CFrame, partToLookAt.CFrame * (dir + (partToLookAt.Size * dir) / 2)
Part.CFrame = cf

Something like that.
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