|
| 14 Nov 2017 11:25 PM |
if i have a CFrame such as: CFrame.new(3,-1,-8) * CFrame.Angles(.2,-math.pi/2,-math.pi/2) how could I add a vector3 to it such that the new CFrame would be CFrame.new(0,-1,-8) * CFrame.Angles(.2,-math.pi/2,-math.pi/2)
this is boggling my mind...
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 14 Nov 2017 11:39 PM |
To add on to @CntKillMe's response, since you aren't changing the rotation of the CFrame, just the position, you are essentially "sliding" (technically known as "translating") the CFrame in the 3D space.
Mathematically, you can translate a point (the position) by adding a vector to it. Hence the answer above.
|
|
|
| Report Abuse |
|
|
|
| 14 Nov 2017 11:46 PM |
WillieTehWierdo200 & cntkillme
youre right. I made a mistake. how would I translate the position when the rotation is variable?
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Nov 2017 11:49 PM |
so you want to translate in world space or in the object space of the CFrame? That is do you want it to go left 3 studs no matter the rotation or have it go towards its left 3 studs? |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2017 11:49 PM |
First you would perform the translation (add the Vector3), then you would perform a rotation (multiply by a CFrame.Angles())
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Nov 2017 11:54 PM |
| No if he's translating in world space it doesn't matter if he rotates before he translates. |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Nov 2017 12:23 AM |
okay... what if I don't know the exact angles. Rather, I have I need to move something locally along the axis of the CFrame. Basically, I want to add Vector3.new(-3,0,0) along the orientation of the CFrame I am adding the vector to. Originally I thought PointToObjectSpace did this but now I'm not so sure.
|
|
|
| Report Abuse |
|
|
|
| 15 Nov 2017 12:28 AM |
| I know that if I have a CFrame with rotation: # # # # # # # # # then the corresponding Vector3 translation would just be -3,0,0 but if the axes were all rotated then the absolute Vector3 translation won't work anymore. |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2017 12:30 AM |
rotation: (the rotation matrix of a CFrame that lines up with the world axes) trying to type ones and zeros gets hashtagged ugh.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Nov 2017 01:16 AM |
CFrame * CFrame does that
part.CFrame = part.CFrame * CFrame.new(5, 0, 0)
would move it 5 units to ITS right |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2017 01:38 AM |
ahh. One more thing. If I wanted to add a vector amount to a CFrame like before but instead of translating it by the CFrame's space, I want to add the vector to the CFrame along the axes of another CFrame with a different orientation than the CFrame I'm adding to.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Nov 2017 02:00 AM |
You can use vectorToWorldSpace for that
CF1 + CF2:vectorToWorldSpace(objSpaceOfCF2Vector) |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2017 11:21 AM |
I was about to type how I was confused but I think I am starting to get it now.... thank you.
|
|
|
| Report Abuse |
|
|