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 » Scripters
Home Search
 

Calculating angle between two points?

Previous Thread :: Next Thread 
pericuIosa is not online. pericuIosa
Joined: 17 Dec 2016
Total Posts: 70
10 Mar 2017 11:27 AM
(prntscr)
/eicfh9

Is this accurate (assuming I don't need to go back and learn trigonometry all over again)?
I tried it in a script and I get weird rotations. I want the camera to rotate on the Y axis (up and down) relative to the character's head.
Report Abuse
RogueMage is not online. RogueMage
Joined: 28 Jan 2012
Total Posts: 1235
10 Mar 2017 11:30 AM
I think you have to rotate it on the X-axis or Z-axis as you're rotating up and down. If you think about it like bars, then when you rotate up and down you're rotating along a horizontal bar (x and z), not a vertical bar(y).
Report Abuse
pericuIosa is not online. pericuIosa
Joined: 17 Dec 2016
Total Posts: 70
10 Mar 2017 11:52 AM
I'm not sure what you mean. Could you elaborate a little?
Report Abuse
pericuIosa is not online. pericuIosa
Joined: 17 Dec 2016
Total Posts: 70
12 Mar 2017 04:24 AM
I've tried math.atan2() and it works to an extent - but when I use my mouse to move the character (mouse is locked in the center of the screen), the angle starts going crazy.

Does anyone know why this is happening?
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
12 Mar 2017 04:25 AM
atan2 gives angles between -90 and 90


Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
12 Mar 2017 04:25 AM
wait nvm didn't read your thing right


Report Abuse
pericuIosa is not online. pericuIosa
Joined: 17 Dec 2016
Total Posts: 70
12 Mar 2017 04:31 AM
https://www.roblox.com/games/673627868/Space

Here's what I've got if you want to see for yourself.
Report Abuse
pericuIosa is not online. pericuIosa
Joined: 17 Dec 2016
Total Posts: 70
12 Mar 2017 05:20 AM
Bump?
Report Abuse
Zylez is not online. Zylez
Joined: 26 Mar 2016
Total Posts: 417
12 Mar 2017 05:41 AM
vector = Pos2 - Pos1

angle = math.deg(math.atan(Vector.X/Vector.Z))
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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