I want to get the direction I showed in bottom part of the drawing. What should I do? Sorry I really don’t know much about the mathematical logic of this
Do you want to get the angle, or the WorldSpace of the LookVector direction?
If you want to get the angle, I suggest you look at this post I’ve made covering this exact function: How would I make this NPC look at me while walking? - #9 by edozune
If you wanted to just convert their LookVector into WorldSpace orientation, then you would use the HRP.CFrame’s function called “VectorToWorldSpace
” to turn their forward direction into a global rotated vector.
HRP.CFrame:VectorToWorldSpace(HRP.CFrame.LookVector)
Hopefully this helps, and good luck on your project. (Consider marking this post as a solution to help others who might be looking for the same answer.)
I didn’t really understand so I am writing again to make the question more clear. I will shoot a projectile to where character is looking at. That is easy because LookVector exists right? But what should I do if I want to shoot it like this?
So like to floor instead of straight.
… Then you would just go with the WorldSpace option, just adding a negative value for Y since that controls the upward angle of the vector.
HRP.CFrame:VectorToWorldSpace(HRP.CFrame.LookVector + Vector3.new(0, -1, 0))
-- or you could do
HRP.CFrame:VectorToWorldSpace(Vector3.new(0, 1, 1)) -- LookVector is basically the Z property
Just add/multiply the vector with the negative UpVector
… or something like that.
Unless you’re looking for definitely global direction of down, just use Vector3.new(0, -1, 0)
added on top of it. Remember to clamp it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.