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: Face block towards mouse on one axis

Previous Thread :: Next Thread 
nightninja53 is not online. nightninja53
Joined: 11 Oct 2009
Total Posts: 332
23 Mar 2015 05:19 PM
Trying to get a block to point where the mouse is, but I need it to rotate solely on the Y axis. The block rotates randomly and doesn't point to the mouse however.
And if I try to use CFrame instead of an Objectvalue, everything freaks and flies away!?

mouse.Move:connect(function()
local dir=(mouse.Hit.lookVector)
script.Parent.Parent.ObjectValue.Value.C0 = script.Parent.Parent.ObjectValue.Value.C0 * CFrame.Angles(0,dir.x,0)
end)
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
23 Mar 2015 05:47 PM
Did you know joints (welds and such) work on object-space and not world-space? For instance,

CFrame.new(0,1,0) on C0 does NOT mean position 0,1,0. It means 0,1,0 offset from Part0. So setting C0 to

C0 = CFrame.new(0,1,0)

Is the same as setting a brick's position to:

Brick.Position = Weld.Part0.Position + Vector3.new(0,1,0)

Get what I'm saying? Also, please do not use C0 unless you are using rotate joints (Rotate, RotateP, RotateV). For welds, use C1 to adjust Part1. Here's how you do what you want.

mouse.Move:connect(function()
local Weld = script.Parent.Parent.ObjectValue.Value;
Weld.C1 = (CFrame.new(Weld.Part1.Position, mouse.Hit.p)):toObjectSpace(Weld.Part0.CFrame * Weld.C0);
end)
Report Abuse
nightninja53 is not online. nightninja53
Joined: 11 Oct 2009
Total Posts: 332
23 Mar 2015 07:11 PM
The block faces the mouse now, but it doesn't rotate on a single axis.
Also can you help explain what this does? (Weld.Part0.CFrame * Weld.C0)
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
23 Mar 2015 07:22 PM
My bad, I forgot about that part:

mouse.Move:connect(function()
local Weld = script.Parent.Parent.ObjectValue.Value;
Weld.C1 = (CFrame.new(Weld.Part1.Position, Vector3.new(mouse.Hit.p.x,Weld.Part1.Position.Y,mouse.Hit.p.z))):toObjectSpace(Weld.Part0.CFrame * Weld.C0);
end)
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