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: how do I find the lookvector of a brick

Previous Thread :: Next Thread 
Eggnivia is not online. 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 is not online. powertool
Joined: 01 Feb 2008
Total Posts: 3771
03 Nov 2014 12:07 AM
CFrame.lookVector.x and CFrame.lookVector.z
Report Abuse
Eggnivia is not online. 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 is not online. Eggnivia
Joined: 30 May 2009
Total Posts: 4144
03 Nov 2014 02:21 AM
bump
Report Abuse
murcury57 is not online. murcury57
Joined: 30 Jun 2010
Total Posts: 90299
03 Nov 2014 06:31 AM
[ Content Deleted ]
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
03 Nov 2014 06:32 AM
Follow me k
Report Abuse
RoflBread is not online. 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 is not online. murcury57
Joined: 30 Jun 2010
Total Posts: 90299
03 Nov 2014 07:03 AM
[ Content Deleted ]
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
03 Nov 2014 07:04 AM
^^
Report Abuse
murcury57 is not online. murcury57
Joined: 30 Jun 2010
Total Posts: 90299
03 Nov 2014 07:07 AM
[ Content Deleted ]
Report Abuse
RoflBread is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
03 Nov 2014 07:48 AM
Ah sweet. Glad to help.
Report Abuse
K7Q is not online. 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
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