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
 

Re: Pointing a part towards a position using cframe?

Previous Thread :: Next Thread 
popdosprlte is not online. popdosprlte
Joined: 18 Dec 2009
Total Posts: 4801
23 May 2013 03:55 PM
Hello! I can't figure how to point a part's front face towards a location using cframe's rotation. Can my fellow scripters help me?
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
23 May 2013 03:57 PM
What are you wanting it to point towards?
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
23 May 2013 03:58 PM
"using CFrame's rotation"

I'm going to assume you don't mean:

CFrame.new(Part.Position, lookAt)

If it is, great, if not, then I can help with any matrix math you might want.
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
23 May 2013 03:59 PM
Isn't that lookVector?
Report Abuse
popdosprlte is not online. popdosprlte
Joined: 18 Dec 2009
Total Posts: 4801
23 May 2013 04:00 PM
I'm basically just trying to emulate how the bodygyro object works, but for only a breif second, and instantaneously.

I usually don't play around much with CFrames but I'll try your tidbit of code.


For The Curious: I'm trying to aim a rocket.
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
23 May 2013 04:00 PM
I'm going to make a general example for you;

This points the brick to the location of the nearest player's torso, but only within a set distance.
It can be edited to point wherever you wish if it's what you're looking for.




function findTorso(pos)
local torso = nil
local dist = 1000
local child = workspace:children()
for i=1, #child do
if child[i].className == "Model" then
local h = child[i]:findFirstChild("Humanoid")
if h ~= nil then
local check = child[i]:findFirstChild("Torso")
if check ~= nil then
if (check.Position - pos).magnitude < dist then
torso = check
dist = (check.Position - pos).magnitude
end
end
end
end
end
return torso
end

while true do
wait()
local torso = findTorso(script.Parent.Position)
if torso ~= nil then
script.Parent.CFrame = CFrame.new(script.Parent.Position, torso.Position)
end
end
Report Abuse
popdosprlte is not online. popdosprlte
Joined: 18 Dec 2009
Total Posts: 4801
23 May 2013 04:02 PM
Solved it.

Thanks for helping guys.

I was doing what MrNic posted originally, but I kept adding the part's CFrame to it's cframe.

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