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: Creating a Part in front of the Camera

Previous Thread :: Next Thread 
Piedude777 is not online. Piedude777
Joined: 01 Oct 2008
Total Posts: 10017
16 Aug 2011 02:49 PM
Hai, guys. I'm working on a plugin and I need to know of a way to create a part in front of the camera. I'm pretty sure I need to use the camera's lookVector, but I'm not sure how.

cam = game.Workspace.Camera
part = Instance.new("Part", Workspace)
part.Position = cam.CoordinateFrame.p

That creates the part where the camera is, but how you I create it in front of the camera?

Report Abuse
RawrBot is not online. RawrBot
Joined: 22 Aug 2008
Total Posts: 832
16 Aug 2011 03:04 PM
(Works in Studio Mode, not sure Online)
cam=workspace.Camera
workspace.Part.Position=cam.CoordinateFrame.p+(cam.CoordinateFrame.lookVector)*10

:D
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
16 Aug 2011 03:06 PM
Sure feels odd trying to help someone with 30 times as many posts :D

I think lookVector would be correct, but having it normalized would allow control over the distance at which the part spawns.

distance = 10
cam = game.Workspace.Camera
part = Instance.new("Part", Workspace)
part.Position = cam.CoordinateFrame.lookVector.unit * distance


Give that a run. =)

Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
16 Aug 2011 03:07 PM
*Slaps head* Ah yes and be sure to add the cameras position to the normalized vector. Silly me...
Report Abuse
Piedude777 is not online. Piedude777
Joined: 01 Oct 2008
Total Posts: 10017
16 Aug 2011 03:07 PM
Thank you, sir.
:)

~ Dumbledore ~
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
16 Aug 2011 03:10 PM
"I think lookVector would be correct, but having it normalized would allow control over the distance at which the part spawns."

lookVector is a unit vector. :3
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
16 Aug 2011 03:48 PM
Lies! :'(
Report Abuse
RawrBot is not online. RawrBot
Joined: 22 Aug 2008
Total Posts: 832
16 Aug 2011 04:25 PM
Truth! LookVector is a direction, according to my working script way above. xD
Report Abuse
Kartheron2 is not online. Kartheron2
Joined: 15 Feb 2009
Total Posts: 478
16 Aug 2011 04:34 PM
Don't you need to use CurrentCamera?

Like:

cam = Workspace.CurrentCamera?

I may be wrong, i've never used cameras before, but I know I read that.
Report Abuse
Piedude777 is not online. Piedude777
Joined: 01 Oct 2008
Total Posts: 10017
16 Aug 2011 04:36 PM
@ Karth

I'm using a plugin.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
16 Aug 2011 04:36 PM
@Karth
Since he's using a plugin, CurrentCamera is not needed.
Report Abuse
RawrBot is not online. RawrBot
Joined: 22 Aug 2008
Total Posts: 832
16 Aug 2011 04:39 PM
Yes I forgot to convert it to CurrentCamera.

But it works in Studio Mode as promised, maybe not Online.
Report Abuse
RawrBot is not online. RawrBot
Joined: 22 Aug 2008
Total Posts: 832
16 Aug 2011 04:40 PM
Yeah what AFF said. xD
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