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: X axis aiming

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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 is not online. 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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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 is not online. 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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 04:04 PM
Tuple? wtf is that even a real word?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
18 Oct 2014 04:07 PM
Tuple is a real word hehe
Report Abuse
maxomega3 is not online. 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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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 is not online. 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 is not online. 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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 04:23 PM
@ eLunate like this?
A, B, C = 1, 2, 3

Report Abuse
eLunate is not online. 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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 04:35 PM
ok well i suppose we should get back to the issue now please lol


Report Abuse
eLunate is not online. 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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 05:19 PM
bump
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 06:05 PM
bump
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 07:36 PM
bump
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 09:49 PM
bump
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
18 Oct 2014 10:47 PM
bump
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Oct 2014 10:55 PM
What a bloc.

Did you even read my post? Waste of my time.
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