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
 

Re: If I wanted to move a player to the right

Previous Thread :: Next Thread 
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
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
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
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 is not online. 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 is not online. 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
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
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 is not online. 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
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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
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