|
| 11 Apr 2013 05:48 PM |
| i basically want to know how to cframe a part (lets say part1) to another part (part2) that acts exactly like a weld except i can rotate using cframe. I know enough about cframing that this will prob need to use lookvector, which is something im not very good with. could someone fill me in? |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 05:55 PM |
| I have already made a script that keeps the part1 the exact same spot away from part2, but my problem is making part1 rotate with part2 when part2 rotates, like a weld. the most i have been able to do is make the part1 have the same cframe as part2, but stay the same distance away. |
|
|
| Report Abuse |
|
|
dnic1997
|
  |
| Joined: 08 May 2010 |
| Total Posts: 309 |
|
|
| 11 Apr 2013 06:03 PM |
function Revolve(p, p2, n) local rweld = Instance.new("Weld", p2) rweld.Part0 = p2 rweld.Part1 = p rweld.C0 = CFrame.new(0, 5, 0) coroutine.resume(coroutine.create(function() for i = n, math.huge, 2 do local pos = Vector3.new(math.sin(i/12) * 0.75, 2, math.cos(i/12) * 0.75) rweld.C0 = CFrame.new(pos) wait() wait() end end)) end
Revolve(part, part0, 0) |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:03 PM |
| Heres an easier way to put it. lets say that i want to create a part just to the right of a players arm, no matter which way they are facing, how would i do so? |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:10 PM |
| Doesnt that just weld a part to a part, and make one spin around the other? remember, im trying to use cframe. if its impossible or extremely difficult, i understand, im just wondering if it is possible, what would i do? |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:11 PM |
| Why do you need to do this? Weld's were made to do what you are describing... |
|
|
| Report Abuse |
|
|
dnic1997
|
  |
| Joined: 08 May 2010 |
| Total Posts: 309 |
|
|
| 11 Apr 2013 06:19 PM |
I would say create a weld inside of the part, then make the head, part0 in the weld and make the part, part1. Then move the CFrame to the spot that you would like it to be positioned at. For example:
local weld = Instance.new("Weld", part) weld.Part0 = head weld.Part1 = part weld.C0 = CFrame.new(head.Position + Vector3.new(0, 0, 2))
_______________________________________________________________ Something like that. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:20 PM |
Becouse of the scenario i just described.
Lets say that there is a player, and hes spinning around. Lets also say i want a part to be welded to him to the right of his right arm or something. Well if a part isnt there to be welded, how would i make a part appear to the right of his right arm? - something x or z wouldnt work becouse that would just go by the x and z, not the direction the part is facing. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:22 PM |
| Just use another weld... Weld another arm to his current arm. What you are planning on doing what be very laggy. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:29 PM |
| Ok, well lag or not im just asking if its possible and how so. im not planning on making this constant. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:32 PM |
Yes it is possible but it is stupid....
while wait(waittime) do fakeArm.CFrame = realArm.CFrame + ((realArm.lookVector)*CFrame.Angles(turntorightiforgettheangle)) end |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:34 PM |
I believe the angle is
CFrame.Angles(0,-math.pi/2,0) |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 11 Apr 2013 06:38 PM |
| I see what he's saying, and it is actually where I am stuck on the game I'm making. They should make a roblox function for it |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:52 PM |
| Its erroring. something about a number expected, got no value. that and i had to put realarm.CFrame.lookVector.. :/ |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 06:55 PM |
| nvm, i put cframe new into the cframe.new. lol. one second. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:03 PM |
| Ok, so it works, But all its doing is jumping to the fakearms pos and having the same cframe as fakearm. what i need to do is, well, what i said... i dont want to use a fake arm as basically the spot to weld on, i want to figure out the math to calculate the spot. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:05 PM |
You tried this formula?
fakeArm.CFrame = realArm.CFrame + ((realArm.lookVector)*CFrame.Angles(0,math.pi/2,0)) |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:08 PM |
| Yes. What that did is essentially the same thing as making a parts cframe = the welded parts cframe. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:19 PM |
| Ok, i figured out a way of my own, which basically makes a part which equals the right arm's cframe. then i make this part look at the torso, and subtract its z position using the lookvector. one second, ill get it up once im finished |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:20 PM |
| lol mine did pretty much da same ting..... |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:33 PM |
l = Instance.new("Part") l.Parent = game.Workspace l.Size = Vector3.new(1,1,4) l.BrickColor = BrickColor.new("White") l.Anchored = true l.CanCollide = false
rarm = game.Workspace.sloomingbla:FindFirstChild("Right Arm") torso = game.Workspace.sloomingbla.Torso
for i=1,5000 do
l.CFrame = rarm.CFrame oldcf = l.CFrame - l.Position l.CFrame = CFrame.new(l.Position,torso.Position) m = (l.Position - torso.Position).magnitude pos = torso.Position+ l.CFrame.lookVector*(-m - 3) l.CFrame = oldcf + pos wait(0.001)
end
Although laggy, lol, this makes a part 3 studs away from the right arm, that acts exactly like it is welded. |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:33 PM |
| I don't see how that helps you at all? |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 07:36 PM |
| It helps becouse it finds the position to the right of the player, where i can create a part then weld. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 11 Apr 2013 08:02 PM |
local character = ? -- Set the character yourself local rightVector = character.Torso.CFrame:vectorToWorldSpace(Vector3.new(1,0,0))
-- This creates a part to the right of the character no matter where it's facing: local p = Instance.new("Part", Workspace) p.Anchored = true while wait() do p.CFrame = character.Torso.CFrame + (rightVector * 3) rightVector = character.Torso.CFrame:vectorToWorldSpace(Vector3.new(1,0,0)) end |
|
|
| Report Abuse |
|
|
|
| 11 Apr 2013 08:12 PM |
Oh, thanks. Lol my way is horrible, but as long as it works right? Wish you were here sooner...
|
|
|
| Report Abuse |
|
|