Eggnivia
|
  |
| Joined: 30 May 2009 |
| Total Posts: 4144 |
|
|
| 02 Nov 2014 11:23 PM |
| eg. I want to know how many degrees/radians the player would have to turn to be facing an invisible brick (for a compass) because I've read over some scripts and I've no clue. |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 03 Nov 2014 12:07 AM |
| CFrame.lookVector.x and CFrame.lookVector.z |
|
|
| Report Abuse |
|
|
Eggnivia
|
  |
| Joined: 30 May 2009 |
| Total Posts: 4144 |
|
|
| 03 Nov 2014 12:16 AM |
| I know that, but I don't know what to do from there. Because the player's lookVector doesn't move so if I just do player lookvector-brick lookvector I'm going to get a result that's only true if the player stood still, so how do I implement player position into this equation? |
|
|
| Report Abuse |
|
|
Eggnivia
|
  |
| Joined: 30 May 2009 |
| Total Posts: 4144 |
|
| |
|
murcury57
|
  |
| Joined: 30 Jun 2010 |
| Total Posts: 90299 |
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 03 Nov 2014 06:58 AM |
V1 = InvisibleBrick.Position V2 = V1 - Torso.Position LV = Torso.CFrame.lookVector
angle = math.deg(math.acos(V1.Unit:Dot(V2.Unit))) |
|
|
| Report Abuse |
|
|
murcury57
|
  |
| Joined: 30 Jun 2010 |
| Total Posts: 90299 |
|
| |
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
| |
|
murcury57
|
  |
| Joined: 30 Jun 2010 |
| Total Posts: 90299 |
|
| |
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 03 Nov 2014 07:08 AM |
Fixed
V1 = InvisibleBrick.Position V2 = V1 - Torso.Position LV = Torso.CFrame.lookVector
angle = math.deg(math.acos(LV:Dot(V2.Unit)))
A • B = |A||B|Cos(Θ)
Make A and B unit vectors (a length of 1), and it cancels down to
A • B = Cos(Θ)
Which you can easily get the angle from. |
|
|
| Report Abuse |
|
|
Eggnivia
|
  |
| Joined: 30 May 2009 |
| Total Posts: 4144 |
|
|
| 03 Nov 2014 07:08 AM |
I already know about that, bread, but thanks
I'm trying to get the angle of the torso from the brick without it giving an incorrect result if the player moves further or closer on the same degree, because that's currently what's happening.
Eg the lookvector will be correct but the number will increase or decrease as if it's using magnitude or something like that. |
|
|
| Report Abuse |
|
|
Eggnivia
|
  |
| Joined: 30 May 2009 |
| Total Posts: 4144 |
|
|
| 03 Nov 2014 07:15 AM |
| What's the symbol between A and B? I'm confused. |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 03 Nov 2014 07:20 AM |
@murcury
18. I bounced around a few colleges in my first year, and things just didn't go well afterwards. You're right though. Essentially I dropped out after 2 years with nothing to show for it, which is pretty bad considering most of my friends are at uni and I'm sat here playing Roblox :-D
@egg
The dot just refers to the dot product (Ax * Bx + Ay * By + Az * Bz). If you used the code in my first post, that was wrong. If not I'll take a look in the studio and tinker with it. |
|
|
| Report Abuse |
|
|
Eggnivia
|
  |
| Joined: 30 May 2009 |
| Total Posts: 4144 |
|
|
| 03 Nov 2014 07:35 AM |
The second script you supplied worked, I can't thank you enough. I've been stuck on that for around 2 days and it got to the point where I was trying combinations of texts that I didn't understand. I'm surprised that it were this simple, because I had around 500 lines of stuff that I tried and changed to a comment if it failed, to keep it for reference.
derp |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
| |
|
K7Q
|
  |
| Joined: 23 Mar 2013 |
| Total Posts: 5546 |
|
|
| 03 Nov 2014 09:50 AM |
| there is a free model compass you can learn off of... |
|
|
| Report Abuse |
|
|