|
| 14 Aug 2012 06:53 AM |
| Can someone explain what (Position1 - Position2).unit achieves? |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 14 Aug 2012 07:44 AM |
| Sort of, the way that Position1 has to face to reach Position2. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 14 Aug 2012 07:53 AM |
| BodyVelocity.velocity = CFrame.new(Position1, Position2).lookVector * SPEED |
|
|
| Report Abuse |
|
|
|
| 14 Aug 2012 07:57 AM |
BodyVelocity.velocity = CFrame.new(Position1, Position2).lookVector * (17 - (Position1 - Position2).magnitude)
Thx |
|
|
| Report Abuse |
|
|