|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 16 Aug 2011 03:07 PM |
Thank you, sir. :)
~ Dumbledore ~ |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 16 Aug 2011 04:36 PM |
@ Karth
I'm using a plugin. |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2011 04:36 PM |
@Karth Since he's using a plugin, CurrentCamera is not needed. |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 22 Aug 2008 |
| Total Posts: 832 |
|
| |
|