|
| 02 Mar 2015 05:53 PM |
no matter which way I'm facing, would I use BodyForces or Velocity of the Torso? I remember one will go based on what the actual X Y and Z is, but the other is based on the rotation etc.
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2015 05:57 PM |
function MoveCharacterDirection(Character,Direction) Character:MoveTo((Character:WaitForChild("Torso").CFrame*Direction).p) end
to move the character 5 studs to the right(or left, not sure) you would do this
MoveCharacterDirection(character,Vector3.new(5,0,0))
Assuming that there isn't anything in their way, otherwise it will place them on top of the object. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 02 Mar 2015 06:04 PM |
function MoveNPCToOffset(npc,origin,offset) local hum,re = npc:FindFirstChild('Humanoid') if hum then re = hum:MoveTo((origin.CFrame * offset).p) else re = print('No humanoid found;) end return re end
--USAGE-- local npc = workspace.NPC local origin = npc.Torso local offset = CFrame.new(10,0,0)
MoveNPCToOffset(npc,origin,offset) --Will move the NPC 10 studs to the right |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 02 Mar 2015 06:05 PM |
Typo;
function MoveNPCToOffset(npc,origin,offset) local hum,re = npc:FindFirstChild('Humanoid') if hum then re = hum:MoveTo((origin.CFrame * offset).p) else re = print('No humanoid found') end return re end |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2015 06:10 PM |
I'm looking for more of a jump movement. I need it to move forward, that's why I was trying bodyforces etc.
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 02 Mar 2015 06:16 PM |
Then...
function ForceByOffset(origin,offset) local re if origin then local b = Instance.new('BodyPosition',origin) if offset then b.force = (origin.CFrame * offset).p else b:Destroy() return print('offset is nil') end else return print('origin is nil') end end
--USAGE-- local origin = workspace.NPC.Torso local offset = CFrame.new(10,0,0) ForceByOffset(origin,offset) |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2015 06:26 PM |
| It depends. A BodyForce will add a force, meaning it will change the net force/acceleration of your character. A BodyVelocity will add a constant velocity to it without adding any force. I'm guessing you want to use a BodyForce if you want kind of a 'jumping motion'. |
|
|
| Report Abuse |
|
|