golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
|
| 23 Dec 2015 10:17 AM |
I don't know how to add rotation to this, please help
tool = script.Parent player = game.Players.LocalPlayer game.Workspace.Model.PrimaryPart = game.Workspace.Model.Mainpart mainpart = game.Workspace.Model.Mainpart tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "h" then for i = 1,9 do game.Workspace.Model:SetPrimaryPartCFrame(CFrame.new(mainpart.CFrame.x,mainpart.CFrame.y + mainpart.CFrame.y/i, mainpart.CFrame.z)) mainpart.Anchored = true wait(0.01) mainpart.Anchored = false end end end) end)
|
|
|
| Report Abuse |
|
|
Metology
|
  |
| Joined: 06 Oct 2014 |
| Total Posts: 3255 |
|
| |
|
golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
|
| 23 Dec 2015 10:41 AM |
| What do I do then because I'm using a model and I can't just do position and rotation to a model, I have to use the "SetPrimaryPartCFrame" to be able to move it |
|
|
| Report Abuse |
|
|
Metology
|
  |
| Joined: 06 Oct 2014 |
| Total Posts: 3255 |
|
|
| 23 Dec 2015 10:42 AM |
You can only multiply CFrames
Are you doing Camera Manipulation? |
|
|
| Report Abuse |
|
|
golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
|
| 23 Dec 2015 11:09 AM |
I'm making a model jump when I hit the key on the keyboard, it works but the problem is that it always looks to the same direction and doesn't have a free 360 jumps (I'm not sure I'm explaining this well enough) |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2015 11:11 AM |
"You can only multiply CFrames" You know what he meant, stop being a smart-mouth. (Hypocrisy ftw) When you use the multiplication operator, you are adding them. |
|
|
| Report Abuse |
|
|
golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
|
| 23 Dec 2015 11:12 AM |
| The rotation of X,Y,Z is always at 0,0,0 and I want it to be for the way the model moves |
|
|
| Report Abuse |
|
|
golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
|
| 23 Dec 2015 11:18 AM |
I'm not sure how or where to add the multiplication operator, could you edit this line for me?
game.Workspace.Model:SetPrimaryPartCFrame(CFrame.new(mainpart.CFrame.x,mainpart.CFrame.y + mainpart.CFrame.y/i, mainpart.CFrame.z)) |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2015 11:21 AM |
| I don't think you are. Do you want to set a specific rotation, or do you want to make it keep the current rotation? |
|
|
| Report Abuse |
|
|
golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
|
| 23 Dec 2015 11:24 AM |
| Current rotation I believe(Does that mean like the last rotation before the script activates?) |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2015 11:28 AM |
Yeah, or before this part of the script.
game.Workspace.Model:SetPrimaryPartCFrame(CFrame.new(mainpart.CFrame.x,mainpart.CFrame.y + mainpart.CFrame.y/i, mainpart.CFrame.z, select(4, workspace.Model:GetPrimaryPartCFrame():components()))) |
|
|
| Report Abuse |
|
|
golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
| |
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 23 Dec 2015 11:48 AM |
or something like
local cf = workspace.Model:GetPrimaryPartCFrame()
workspace.Model:SetPrimaryPartCFrame(CFrame.new(your stuff here) * (cf-cf.p)) |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Dec 2015 11:55 AM |
My way took 15.488 seconds for 10,000,000 iterations. Your way took 20.364 seconds for 10,000,000 iterations.
Of course, I didn't use the exact code as what was posted here, but the code I used was the same each time.
local start = tick() for n = 1, 10000000 do local cf = workspace.BasePlate.CFrame local cf2 = CFrame.new(50, 25, 50, select(4, cf:components())) end print(tick() - start)
local start = tick() for n = 1, 10000000 do local cf = workspace.BasePlate.CFrame local cf2 = CFrame.new(50, 25, 50) * (cf-cf.p) end print(tick() - start) |
|
|
| Report Abuse |
|
|
golangoal
|
  |
| Joined: 26 Apr 2011 |
| Total Posts: 185 |
|
|
| 23 Dec 2015 12:04 PM |
What is the difference with what rvox wrote? I tried it and couldn't make it work, probably because I'm a beginner at scripting, it says P is not a valid member of part
|
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 23 Dec 2015 12:06 PM |
you copied it wrong
they do the same thing |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2015 12:06 PM |
Rvox's method takes the CFrame (Containing position and rotation) and subtracts the position (So it contains just rotation, the position being 0)
workspace.Model:SetPrimaryPartCFrame(CFrame.new(your stuff here) * (Part.CFrame-Part.CFrame.p))
My method is apparently a bit faster, but it doesn't matter too much. |
|
|
| Report Abuse |
|
|