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: Part following camera?

Previous Thread :: Next Thread 
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 01:31 PM
Hello, is there a way I can make a part look the way the camera is looking? Like when the mouse moves right, the camera moves right and the parts also moves right.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 01:51 PM
Bump

I think you have to use a local script.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 02:07 PM
Bump

I think you have to use the mouse hit function, but how do you use it?
Report Abuse
noobertuber is not online. noobertuber
Joined: 16 Jan 2007
Total Posts: 2321
25 Mar 2012 02:37 PM
Well, you'd need to use a local script. Take the lookvector of the coordinate frame of the camera, and set the parts CFrame to something like the following:

part.CFrame = CFrame.new(part.Position, part.Position+cameralookvector)

Sincerely,
Noobertuber
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 02:40 PM
I knew I needed to use lookvector, but how do I get it?

So, something like this?

cam=workspace.CurrentCamera
part=workspace.Part
while true do
part.CFrame = CFrame.new(part.Position, part.Position+cameralookvector)
wait()
end
Report Abuse
MasterAnimation200 is not online. MasterAnimation200
Joined: 25 May 2008
Total Posts: 1451
25 Mar 2012 02:44 PM
You're doing it wrong.

local cam = workspace.CurrentCamera
local cf = cam.CoordinateFrame
local foc = cam.Focus
local p = Instance.new("Part")
p.Parent = workspace
p.CFrame = CFrame.new(cf.p,foc.p)

Report Abuse
MasterAnimation200 is not online. MasterAnimation200
Joined: 25 May 2008
Total Posts: 1451
25 Mar 2012 02:49 PM
Here's what you want, there are some flaws in my previous code:

local cam = workspace.CurrentCamera
local cf = cam.CoordinateFrame
local foc = cam.Focus
local p = Instance.new("Part")
p.Anchored = true
p.FormFactor = ("Custom")
p.Size = Vector3.new(1,1,1)
p.Parent = workspace
while wait() do
p.CFrame = CFrame.new(cf.p,foc.p)
end
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 02:52 PM
Thanks. I modified it a bit. But can I do this with the players head?

local cam = workspace.CurrentCamera
local cf = cam.CoordinateFrame
local foc = cam.Focus
p = workspace.Head

while true do
local cf = cam.CoordinateFrame
local foc = cam.Focus
p.CFrame = CFrame.new(cf.p,foc.p)
p.Position=Vector3.new(0,20,0)
wait()
end
Report Abuse
MasterAnimation200 is not online. MasterAnimation200
Joined: 25 May 2008
Total Posts: 1451
25 Mar 2012 02:56 PM
Moving the head of a player will probably kill him/her. Here's how you would instead do:
--Assuming you have the localscript inside the player's character:
local cam = workspace.CurrentCamera
local torso = script.Parent:FindFirstChild("Torso")
local cf
local foc
while wait() do
cf = cam.CoordinateFrame
foc = cam.Focus
torso.CFrame = CFrame.new(cf.p,foc.p) * CFrame.new(0,-3.2,0)
end
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Mar 2012 02:58 PM
You could use the neck 6D motor.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 03:00 PM
What's the neck 6D motor?
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 03:03 PM
MasterAni, that script makes you fly everywhere. You can't move the head, but if you did, it would kill you.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 03:04 PM
thek00lkid said something about a neck 6D motor?
Report Abuse
MasterAnimation200 is not online. MasterAnimation200
Joined: 25 May 2008
Total Posts: 1451
25 Mar 2012 03:13 PM
Uh, I thought I made it clear that moving the head would cause you to die? Hence the reason why I switched to torso. I don't need you to tell me that. I know it makes you fly everywhere. How about sticking to making a single part you create follow the camera instead? The neck 6D motor is basicly the same as a weld, only difference is that a 6D motor can be used for animations without killing the character.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 03:14 PM
Could I use the Motor6D with just the head to move the head around and not kill the person?
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Mar 2012 03:26 PM
Yes
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 03:28 PM
So would it be the same script, but instead of the cFrame, I should replace it with Motor6D instead?
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Mar 2012 03:30 PM
No, you find out where the camera is pointing, and set the motor's desired angle to where you calculate the camera is pointing.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 03:39 PM
I don't know what I am doing... It's not working.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 03:55 PM
Bump
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 04:27 PM
Bump
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Mar 2012 04:40 PM
Look up camera on the wiki.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 05:11 PM
What I had working before doesn't work in multiplayer. Does anyone know why? I have almost redone it all. You can see it at my head test game. The head doesn't move like it should.
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 05:26 PM
Why doesn't the CFrame part work in multiplayer? This is the part that doesn't work in multiplayer:

cam = workspace.CurrentCamera
cf = cam.CoordinateFrame
foc = cam.Focus

p = script.Parent
cam.CameraSubject=p
cam.CameraType="Follow"

while true do
cf = cam.CoordinateFrame
foc = cam.Focus
p.CFrame = CFrame.new(cf.p,foc.p)

...
Report Abuse
Soapy29 is not online. Soapy29
Joined: 20 Aug 2009
Total Posts: 653
25 Mar 2012 05:55 PM
Bump
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