|
| 10 Apr 2014 08:23 AM |
| How do I make sure that a Part is always in front of the Camera using CFrames? |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 08:25 AM |
| Do you want the camera to follow it? |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 08:27 AM |
No, I would like it to just be placed in front of the Camera. Here's what I've tried:
Part.CFrame = Camera.CoordinateFrame*CFrame.new(5,0,5)
But, of course, that will only work if the Camera is facing in a positive direction. If it faces a negative direction, it will become out of view as it will be situated behind the Camera. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 08:51 AM |
For example, if my Camera's position is {-15,0,-15} and I want my part at {0,0,0}, I can just say Camera.CoordinateFrame+Vector3.new(15,0,15), but if I want to do it the other way around, I'd have to change it to -Vector3.new().
But what would I do if the Camera's position was {-15,0,15} or {15,0,-15}? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Apr 2014 09:30 AM |
| You want it to be 15, 0, -15 studs in front of the camera? (15 studs right and 15 studs forward) Just do: part.CFrame = camera.CoordinateFrame * CFrame.new(15, 0, -15) |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 01:12 PM |
Okay, let me try and explain this better...
I want a Part to always stay in front of my Camera, no matter where I turn it. I can do as you suggested, but that doesn't always assure that it's placed in front of my Camera at all times. If I turn to a certain direction, it'll go behind the Camera, which is not what I want. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 01:59 PM |
maybe you can find the difference between the camera's cframe and the cameras subject and then calculate the position of the part in relation to the difference.
example (not code - make your own :D) #
camera cframe = (20,20,20) camera subject cframe = (15,15,15) difference = (5,5,5) part cframe = camera cframe - (1,1,1) or (2,2,2) / up to difference
going past the difference would put the part behind subject and going inverted on the difference would put the part behind the camera (or vise-versa [logics]) |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 10 Apr 2014 03:23 PM |
part.CFrame = camera.CoordinateFrame * CFrame.new(0,0,-15) * CFrame.new(15,0,0)
or,
part.CFrame = camera.CoordinateFrame:toWorldSpace(15,0,-15)
Dunno, try that. What cnt posted should be working fine, really. |
|
|
| Report Abuse |
|
|