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: How do i rotate an object attached to char?

Previous Thread :: Next Thread 
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 08:30 PM
So if I created the following weld..

arrow = game.ReplicatedStorage.Arrow:Clone()

arrow.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(90))

local Joint = Instance.new("Weld")
Joint.Part0 = arrow
Joint.C0 = arrow.CFrame:inverse()
Joint.Part1 = character.HumanoidRootPart
Joint.C1 = character.HumanoidRootPart.CFrame:inverse()

Joint.Parent = character.HumanoidRootPart
arrow.Parent = character

-- How would I rotate it on its x axis right here
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 08:33 PM

Would enjoy an example :)
Report Abuse
SinisterMemories is not online. SinisterMemories
Joined: 21 Mar 2013
Total Posts: 4892
30 Jan 2017 08:37 PM
Directory.Object.Rotation = Vector3.new(val,val,val)


"Got my cup of Coffee"
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 08:40 PM

How do i do this with CFrames? While also keeping it attached to character, and not rotating character.
Report Abuse
SinisterMemories is not online. SinisterMemories
Joined: 21 Mar 2013
Total Posts: 4892
30 Jan 2017 08:43 PM
uhm i think the joint would break if you tried to rotate it.



"Got my cup of Coffee"
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 08:47 PM

Well, it is possible to do this so how to do it?
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 08:52 PM

Some one help please....
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 Jan 2017 08:52 PM
thing.CFrame = thing.CFrame * CFrame.Angles(x,0,0)


Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 08:55 PM

Good try Time although that rotates character...
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 Jan 2017 08:57 PM
why are you using a weld


Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
30 Jan 2017 08:59 PM
Since its a weld you want to CFrame that:

local X = math.min((tick() - t0) / 1, 1) * 120 --t0 is tick() before the loop

welds[1].C1 = welds[1].C1:lerp(PF1, (X / 90)) --Bad example but its what I use.
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 09:01 PM

Any other examples please..

Time since I want it to be attached to character?
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 09:05 PM
Nvm got your example to work thanks Lua!
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
30 Jan 2017 09:17 PM
<3
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 09:26 PM

Still can't get this to work :(

Want the arrow to rotate and point towards the followPoint position.

=================================================================================

Player = game.Players.LocalPlayer
character = Player.Character
arrow = game.ReplicatedStorage.Arrow:Clone()

arrow.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(90))

local Joint = Instance.new("Weld")
Joint.Part0 = arrow
Joint.C0 = arrow.CFrame:inverse()
Joint.Part1 = character.HumanoidRootPart
Joint.C1 = character.HumanoidRootPart.CFrame:inverse()

Joint.Parent = character.HumanoidRootPart
arrow.Parent = character

while wait() do
local PointingPos = game.Workspace.followPoint.Position
local ArrowPos = Vector3.new(0, 0, 5)
Joint.C0 = CFrame.new(PointingPos, ArrowPos) * Joint.C1 * CFrame.new(0, 0, 5)
end
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 09:31 PM

Can't get the cframe matrix right..
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 09:40 PM

Some one help please, this is really frustrating me...
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
30 Jan 2017 09:52 PM
ahhh have been trying for 20 min now.
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
30 Jan 2017 10:59 PM
change this

Joint.C0=arrow.CFrame:inverse()*character.HumanoidRootPart.CFrame:inverse()
--remove Joint.C1



local i=0
while true do
joint.C1=CFrame.Angles(0,math.rad(i%360),0)
i=i+1
wait()
end

--should spin it on its x if its perfectly upright


Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
31 Jan 2017 10:03 AM

cool I was already able to spin it correctly, just not able to point it in a certain direction using the CFrame.new(Vector3, Vector3).
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
31 Jan 2017 10:10 AM
The method I already created works just fine for spinning in pre-calculated ways. I just need to know how to point the arrow at objects.

---------------------------------------------------------------------------------------

wait(0.1)

Player = game.Players.LocalPlayer
character = Player.Character
arrow = game.ReplicatedStorage.Arrow:Clone()

arrow.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(90))

local Joint = Instance.new("Weld")
Joint.Part0 = arrow
Joint.C0 = arrow.CFrame:inverse()
Joint.Part1 = character.HumanoidRootPart
Joint.C1 = character.HumanoidRootPart.CFrame:inverse()

Joint.Parent = character.HumanoidRootPart
arrow.Parent = character

game:GetService("RunService").RenderStepped:connect(function()
arrow.LocalTransparencyModifier = 0
end)

-- Replace what is bellow to make the arrow point towards a part in game called "Point".

i = 1
while wait() do
i = i + 1
Joint.C0 = CFrame.Angles(0, 0, math.rad(i)) * Joint.C1 * CFrame.new(0, 0, 5)
end
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
31 Jan 2017 10:23 AM

I feel like what I am trying to solve here is fairly simple...
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
31 Jan 2017 10:37 AM
-- Replace what is bellow to make the arrow point towards a part in game called "Point".

i = 1
while wait() do
i = i + 1
Joint.C0 = CFrame.Angles(0, 0, math.rad(i)) * Joint.C1 * CFrame.new(0, 0, 5)
end

-- k

local point = POINT PART.Position

while wait() do
Joint.C0 = CFrame.new(Joint.C0.p, point)
end

let me know if that works, it might not point correctly in which case you'll probably need to use toWorldSpace
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
31 Jan 2017 10:51 AM

Did not seem to work sadly, just made it offset by like 1000 studs bellow and away.

wait(0.1)

Player = game.Players.LocalPlayer
character = Player.Character
arrow = game.ReplicatedStorage.Arrow:Clone()

arrow.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(90))

local Joint = Instance.new("Weld")
Joint.Part0 = arrow
Joint.C0 = arrow.CFrame:inverse()
Joint.Part1 = character.HumanoidRootPart
Joint.C1 = character.HumanoidRootPart.CFrame:inverse()

Joint.Parent = character.HumanoidRootPart
arrow.Parent = character

game:GetService("RunService").RenderStepped:connect(function()
arrow.LocalTransparencyModifier = 0
end)

while wait() do
Joint.C0 = CFrame.new(Joint.C0.p, game.Workspace.Point.Position)
end
Report Abuse
RogueMage is not online. RogueMage
Joined: 28 Jan 2012
Total Posts: 1235
31 Jan 2017 10:56 AM
Try changing Part1 and Part0 around.
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