|
| 18 Oct 2014 03:01 PM |
local M = game.Players.LocalPlayer:GetMouse()
game:GetService("RunService").RenderStepped:connect(function() local Gun = game.Workspace.Test.Base.GunWeld Gun.C0 = CFrame.new(0, 0, 0) * (Gun.Part0.CFrame - Gun.Part0.Position):toObjectSpace(M.hit - M.hit.p) end)
I need that to affect X axis only. Idk how to do it. |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 03:03 PM |
| Gun.C0 = CFrame.new(0, 0, 0) * CFrame.new(Vector3.new(), Vector3.new(M.X,0,0)); |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 03:50 PM |
Except that it doesn't move at all unless my mouse in in the farthest left of the screen, in which the whole thing disappears.
This is the script I made for a cannon turret a long time ago that tracks torsos and it follows only along the X axis
local Offset = Vector3.new(0, 3.7, 0) T.C0 = CFrame.new(Offset,Offset+Vector3.new(1, 0, 1) * (T.Part0.CFrame:pointToObjectSpace(Torso.Position)-Offset))
Perhaps there's a way to apply it to the mouse instead of torsos. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Oct 2014 03:56 PM |
| Get your object space position, but only use its X value? And the rest are retained from the original/relative position |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 04:01 PM |
local Offset = Vector3.new(0, 5, 0) Gun.C0 = CFrame.new(Offset, Offset+Vector3.new(1, 0, 1)) * Gun.Part0.CFrame:pointToObjectSpace(M.X, 0, 0)
That's what I thought I understand you as saying. Apparently I was very very wrong.
16:00:29.231 - Players.xiaoxiao181.PlayerGui.CFrameMouse:11: bad argument #1 to 'pointToObjectSpace' (Vector3 expected, got number) 16:00:29.232 - Script 'Players.xiaoxiao181.PlayerGui.CFrameMouse', Line 11 16:00:29.235 - Stack End
line 11 is the 3rd line there. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Oct 2014 04:03 PM |
| Methinks pointToObjectSpace(Vector3 point) needs a Vector3 instead of a tuple |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 04:04 PM |
| Tuple? wtf is that even a real word? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 18 Oct 2014 04:08 PM |
A tuple is, as what I recall from cntkillme's instilling in me, a parameter that's ... rather than a variable hang on, I forgot what it does... |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 04:10 PM |
| What is a tuple, how does it work, and how am I supposed to just throw in a Vector3 value into that? because i did at first and it told me I need a CFrame. Then I tried a CFrame and it told me i needed a vector3 |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Oct 2014 04:12 PM |
A tuple is an ordered list, and it's usually used (When not explicitly in use for another reason) as tuple args for a function parameter, when you need a variable amount of arguments
|
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 18 Oct 2014 04:14 PM |
For more info: read cntkillme's posts in this thread: http://www.roblox.com/Forum/ShowPost.aspx?PostID=142039136 (also couldn't hurt to read the thread) |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 04:23 PM |
@ eLunate like this? A, B, C = 1, 2, 3
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Oct 2014 04:27 PM |
| Mm, that's a tuple because it's ordered specifically. |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 04:35 PM |
ok well i suppose we should get back to the issue now please lol
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Oct 2014 04:36 PM |
| Yep it needs to be a vector 3 position hehe |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 04:45 PM |
local Offset = Vector3.new(0, 5, 0) Gun.C0 = CFrame.new(Offset, Offset+Vector3.new(1, 0, 1)) * Gun.Part0.CFrame:pointToObjectSpace(Vector3.new(M.X, 0, 0))
Now im not getting any errors but it isnt moving at all. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
| 18 Oct 2014 10:51 PM |
You SHOULD NOT be using C0 for this -.-
Part0 should be the main part and Part1 the legacy (moving part). Thus, your code (object-space handled) would be:
game:GetService("RunService").RenderStepped:connect(function() local Gun = game.Workspace.Test.Base.GunWeld local XHandled = Vector3.new(M.hit.X,Gun.Part1.CFrame.p.y, Gun.Part1.CFrame.p.z); Gun.C1 = (Gun.Part1.CFrame - XHandled):toObjectSpace(Gun.Part0.CFrame * Gun.C0) end)
This will (if you switch your Part0 and Part1 correctly do what you want. You needed to create a separate vector with only the X affected and then transform it to the CORRECT object space location (relative to its main joint). |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 10:54 PM |
Was I supposed to change anything?
Cuz all this did was literally make the turret run off sideways slowly. |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2014 10:55 PM |
What a bloc.
Did you even read my post? Waste of my time. |
|
|
| Report Abuse |
|
|