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: Character movement with BodyVelocity

Previous Thread :: Next Thread 
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:12 PM
I'm trying to get the character to move without the standard controls, or with a BodyVelocity object based on the frame of the camera, like the stand Roblox controls do. Admittingly, I wasn't initially familiar with how this might have worked, so this comes from dissecting free models and help from a friend. The math:

bodyVelocity.velocity = (CFrame.new(0, math.atan2(-1*game.Workspace.CurrentCamera.CoordinateFrame.lookVector.x, -1*game.Workspace.CurrentCamera.CoordinateFrame.lookVector.z), 0)*Vector3.new(x, 0, z)).unit*16

The controls:

mouse.KeyDown:connect(function(key)
if key == "w" then
y = 1
elseif key == "s" then
y = -1
elseif key == "a" then
x = -1
elseif key == "d" then
x = 1
end
end)

A KeyDown negates movement respectively. Any help for me?
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
11 Sep 2013 05:14 PM
What is there to help? The mathematics is correct.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:15 PM
Oops. Got a little ahead of myself. Yes, the mathematics. I assumed it's wrong. What should I use, or where can i find it?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
11 Sep 2013 05:17 PM
A. Trigonometry

B. Did you define mouse?
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:18 PM
Wait, the mathematics IS correct? Huh. It behaves odd. Slowing at different angles, and never leaving the same two axes.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:19 PM
@Bebee2

I have plenty of code to perform my action, I just posted my basic math and control. It works, just not the way I want it. No errors.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:20 PM
And what is

"A. Trigonometry"

supposed to mean? Can't you clearly see this is what I am using, along with a trig function?
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
11 Sep 2013 05:24 PM
Let us interpret the BodyVelocity line.

bodyVelocity.velocity =
Begins to define the velocity.

(CFrame.new(
This will soon be taken as a unit vector.

0,
The x-value is 0.

math.atan2(-1*game.Workspace.CurrentCamera.CoordinateFrame.lookVector.x, -1*game.Workspace.CurrentCamera.CoordinateFrame.lookVector.z)
Okay, so tan(theta) represents the natural intersection of the hypotenuse and the vector that intersects with the side of the triangle, with an origin of the x-axis, right?
So this should the angle at which the tangent has the y-value and x-value have that point of intersection.

,0)
The z-value is zero.

*Vector3.new(x, 0, z)).unit*16
This is pretty obvious. The WalkSpeed is 16, taking the unit, et cetera.
In essence, the mathematics is correct, but the methodology is not. I might explain tomorrow, if the thread is still going without an answer. I must leave.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:26 PM
I know how it works (mostly), I just don't know how I could fix it to behave like I want it to.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:35 PM
Bump.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 05:53 PM
This thread might as well be Absurdism Helpers for me, because it is only he or she that helps me anymore.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 06:34 PM
Bump. Gonna keep bumping until someone helps me.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 06:45 PM
Bump.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 06:49 PM
Bump
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 06:59 PM
Come on people.
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
11 Sep 2013 07:17 PM
Bump
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
12 Sep 2013 07:15 AM
Post the full script, first. Then I'll try to mend it.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
12 Sep 2013 10:53 AM
I cannot tell if this is before or after you PMed me, so I might as well tell you again anyway:

CFrame.Angles, not CFrame.new
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