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: Help with CFraming position and rotation at the same time

Previous Thread :: Next Thread 
golangoal is online. 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 is not online. Metology
Joined: 06 Oct 2014
Total Posts: 3255
23 Dec 2015 10:32 AM
You don't add CFrames
Report Abuse
golangoal is online. 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 is not online. 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 is online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is online. 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 is online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is online. golangoal
Joined: 26 Apr 2011
Total Posts: 185
23 Dec 2015 11:37 AM
Thank you very much!
Report Abuse
rvox is not online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
23 Dec 2015 11:49 AM
Efficiency test! NAO!!!!
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is online. 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 is not online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
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