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: Vector3 Wizards

Previous Thread :: Next Thread 
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 10:49 AM
prntscr/bw6m7z

Basically, given a the lookVector, HumanoidRootPart position, and a movement direction (which is essentially CFrame.new(HumanoidRootPart.CFrame.p,Destination).lookVector) how do I convert the move direction to a Vector in relation to the lookVector?

So basically no matter which way I look, if I'm holding down A (so moving left, this is 100% first person) I will get Vector3.new(0,0,-1). And holding down D, or going right, I will get Vector3.new(0,0,1), etc etc.


- pyth_n
Report Abuse
ray_1 is not online. ray_1
Joined: 18 Feb 2011
Total Posts: 464
22 Jul 2016 10:59 AM
i don't understand what you're saying so i'll just give my best guess

local dir = part.CFrame:vectorToObjectSpace(Vector3.new(1,0,0))
the vector you give to vectorToObjectSpace will be the direction they are supposed to be moving, meaning A will be Vector3.new(-1,0,0), D would be Vector3.new(1,0,0)

please clarify if this is not what you're looking for


Recommended username: FunctionalRay_1


Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:03 AM
Not exactly. I'm trying to determine if a player is moving left, right, forward, back, forward right, forward left, back right, or back left regardless of which way they're looking.


- pyth_n
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
22 Jul 2016 11:04 AM
userinputservice if key is d the left etc. ??
Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:05 AM
nah

more dynamicism


- pyth_n
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
22 Jul 2016 11:08 AM
Look around in the controlscript
Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:10 AM
Basically, im in first person. If i move my mouse around and first person, the movedirection and lookVector both change, but they are the same in relation to each other


- pyth_n
Report Abuse
ray_1 is not online. ray_1
Joined: 18 Feb 2011
Total Posts: 464
22 Jul 2016 11:10 AM
what output would you be expecting in the image


Recommended username: AfraidRay_1


Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:12 AM
so i can rotate the character using my mouse in first person, but it will always output Vector3.new(0,0,-1) because you're moving LEFT in relation to the humanoid root parts look vector.


- pyth_n
Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:13 AM
gonna make a gif, gimme a sec.


- pyth_n
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
22 Jul 2016 11:14 AM
You can use the velocity property of BasePart to get the movement towards each coordinate axis, then interpret each direction based on its sign.
Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:18 AM
gyazo/90f8918511d2e390e83d098d468dfd52

essentially the movedirection is the red line, and the blue line is the look vector. No matter the lookVector I need to get Vector3.new(0,0,-1) because I'm moving left.


- pyth_n
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
22 Jul 2016 11:22 AM
Are you wanted the player's direction of movement or just a vector relative to the player that points in a constant direction? If the latter, you could just use toObjectSpace and to toWorldSpace to get translate back and forth between relative and real-world coordinates.
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
22 Jul 2016 11:23 AM
"Are you wanting the player's direction of movement or just a vector relative to the player that points in a constant direction? If the latter, you could just use toObjectSpace and to toWorldSpace to translate back and forth between relative and real-world coordinates."

fixed grammar
Report Abuse
ray_1 is not online. ray_1
Joined: 18 Feb 2011
Total Posts: 464
22 Jul 2016 11:24 AM
do you mean -1,0,0 for left? because 0,0,-1 is forward


Recommended username: NumerousRay_1


Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:24 AM
I need to essentially which direction the player is moving in relation to the direction they're facing.


- pyth_n
Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:25 AM
@Ray,

probably, i am bad at vectors.

it's one of those. I just know it's not the Y value heheh


- pyth_n
Report Abuse
ray_1 is not online. ray_1
Joined: 18 Feb 2011
Total Posts: 464
22 Jul 2016 11:27 AM
if that's the case then
local dir = root.CFrame:vectorToObjectSpace(movedir)


Recommended username: QuaintRay_1


Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
22 Jul 2016 11:28 AM
Like I said, use the velocity property of BasePart, that will give you how much you're moving on each axis.
Report Abuse
pyth_n is not online. pyth_n
Joined: 21 Jun 2016
Total Posts: 1322
22 Jul 2016 11:30 AM
Thanks ray.

-1.15483999e-006

shows up in the Z value but it's incredibly miniscule and won't matter



- pyth_n
Report Abuse
ray_1 is not online. ray_1
Joined: 18 Feb 2011
Total Posts: 464
22 Jul 2016 11:31 AM
i'm pretty sure velocity is world-space, and i think he wants an object-space vector


Recommended username: NewRay_1


Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
22 Jul 2016 11:31 AM
If you need to know more advanced information such as the angle between the direction a player's head is looking and the direction they are moving, you can do the arccosine of the dot product of the head's velocity vector and lookVector.
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
22 Jul 2016 11:32 AM
@ray_1

It doesn't matter, he can still use toObjectSpace to get it relative to the player's position if it's not already.
Report Abuse
ray_1 is not online. ray_1
Joined: 18 Feb 2011
Total Posts: 464
22 Jul 2016 11:37 AM
well there really is no point converting a vector to a cframe and back again when you can use vectorToObjectSpace to directly get the direction, but you can use the velocity as a direction for vectorToObjectSpace, it should be the same as movedirection


Recommended username: SpookyRay_1


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