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: .unit help?

Previous Thread :: Next Thread 
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
14 Aug 2012 06:53 AM
Can someone explain what (Position1 - Position2).unit achieves?
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
14 Aug 2012 07:25 AM
Something to do with the mouse position of where your character is aiming at (when clicked). It's in a Gun's Firing Script.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
14 Aug 2012 07:33 AM
All that does is get the unit value of Pos1-Pos2, like it reads typed out. What you probably were looking for is magnitude.

(Pos1-Pos2).magnitude

It returns the 'number' distance the two positions are away from each other. However, if you meant the direction of one part facing another, you could do.

CFrame.new(Part1.Position, Part2.Position).lookVector
Report Abuse
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
14 Aug 2012 07:40 AM
I'm looking for the thing like, if you do
(Position1 - Position2).unit
then you have the direct,
then for power,
(Position1 - Position2).unit * 5
for BodyVelocity
Report Abuse
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
14 Aug 2012 07:44 AM
Sort of, the way that Position1 has to face to reach Position2.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
14 Aug 2012 07:53 AM
BodyVelocity.velocity = CFrame.new(Position1, Position2).lookVector * SPEED
Report Abuse
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
14 Aug 2012 07:57 AM
BodyVelocity.velocity = CFrame.new(Position1, Position2).lookVector * (17 - (Position1 - Position2).magnitude)

Thx
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