seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 03:13 AM |
I made a post about this earlier, but got no reply. Is it possible to use a weld to make a brick face the direction of the mouse? |
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Dec 2013 03:27 AM |
If you're trying to make a CFrame look at the mouse just do this
player = game.Players.LocalPlayer mouse=player:GetMouse() brick=game.Workspace.Brick --the brick with the weld in it brick.Weld.C0 = CFrame.new(brick.Position, Vector3.new(mouse.Hit.p.x,mouse.Hit.p.y,mouse.Hit.p.z) |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
| |
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 03:37 AM |
| Tried that. All it did was move my tank's MainGun to a different area. If I moved my mouse, the entire tank gun would move to a different location too. |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 03:37 AM |
| And yes..Weld.C0 is a CFrame.. |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 03:44 AM |
| Try this weld.C0 = = mouse.Hit*CFrame.fromEulerAnglesXYZ(0.1,0,0) |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 03:44 AM |
Oops only 1 equal sign
weld.C0 = mouse.Hit*CFrame.fromEulerAnglesXYZ(0.1,0,0) |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 03:45 AM |
weld.C0 = mouse.Hit*CFrame.fromEulerAnglesXYZ(0.1,0,0) ^This worked for a BodyGyro. I'm not sure about a weld though. |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 03:50 AM |
Doesn't work, same thing as before. I have been trying a lot of things like this for like the past 6 hours.
|
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 03:51 AM |
| I know it works for BodyGyro, but I', trying to avoid using that because it tends to cause lag and is unstable. |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 04:00 AM |
This was the closest I ever got to my goal.
function move(m) while true do
weld.C0 = (weld.C0 * CFrame.Angles(0,m.Hit.y,0)) wait()
end end
It made it spin. _._ I just need to figure out how to make it stop moving once it's looking where the mouse is (this is just to move the gun left or right, not up or down) |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 04:21 AM |
Bump. Btw thanks to those who tried to help. |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
| |
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
| |
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
| |
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 03:22 PM |
Still can't seem to figure out how too. If you can help, please do. lol |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 06:58 PM |
| I would just use BodyGyro at this point xD |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 29 Dec 2013 07:32 PM |
| It's too glitchy. And causes lag. I'm hoping to remove this lag..i'm gonna study Galleons, see how wingman8 did it and see if i can apply it to my model. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 29 Dec 2013 07:37 PM |
Keep aware of the equation for C0:
C0 = Part0.CFrame:inverse()*Part1.CFrame*C1
You can ignore C1.
C0 = Part0.CFrame:inverse()*Part1.CFrame
All you have to do is edit the Part1.CFrame to the CFrame you want the Part1 to be.
That would prolly be the hardest part of the CFraming, though.
|
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 30 Dec 2013 02:26 AM |
| I know that. I'm familiar with using welds to move/rotate bricks. But this is the first time I've ever tried to move a brick in the direction of the mouse.Hit.p |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Dec 2013 02:38 AM |
I'm assuming mouse is the playerMouse and part is the whatever
local offset = (part.Position - mouse.Hit.p) local direction = offset.Unit local angle = math.atan2(direction.X, direction.Z) + math.pi local angle2 = math.atan(direction.Y)
weld.C0 = CFrame.new(weld.C0.p) * CFrame.Angles(0, angle, 0) * CFrame.Angles(angle2, 0, 0)
Not tested. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Dec 2013 02:38 AM |
"local angle2 = math.atan(direction.Y)" Should be "local angle2 = math.asin(direction.Y)" |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 30 Dec 2013 05:20 AM |
Holy crap. It works. Well..almost. It's the inverse. Which one would I change to make it normal? Anyways...THANK YOU. |
|
|
| Report Abuse |
|
|