-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Vector3.project_on_plane() #8173
Comments
What would the difference between this and |
I do not know... I did not know about I will check that out. |
Since |
Looked into 'Plane.project()' and I can get it to do the same thing as my proposed method. But I'm still feeling a These two produce the same result:
But also maybe this is a documentation issue. A hint in the Vector3 class would also have helped me out. |
In this case if you're looking at operating on a |
But that was my problem, I wasn't working with Planes. I wanted to flatten a vector on a surface normal to get the velocity perpendicular to the surface. What I have to work with are Vector3's, and what I wanted was the same. Is creating a Plane like this every frame performant? I might try to test a bit. |
Oh my bad missed the part without the plane, you can simply create a plane with a default position, but I don't think projecting onto a normal like this is a normal operation in this case It's been a while since I did linear algebra so I don't entirely recall |
I think it is more that for this purpose the location and dimensions of the plane are irrelevant; it can be anywhere and infinite in size. I'm looking for the magnitude and directional components of a vector that is perpendicular to another vector (parallel to the plane) so the surface normal is the only data needed. I'm satisfied that Godot has this functionality, but I'd leave my suggestion as is. I think it would be an improvement still. |
That can be done with a plane constructor I think simply with no cost AFAIK, you take a look at the constructors |
|
I'd also advocate for a mention of |
I believe this is
Documentation on
Like this: Given vectors
|
Never heard of sliding a Vector, but that sure sounds like the thing I'm looking for. |
And you won't be alone on that. I'm only aware of Godot calling it that way. And renaming it would be a breaking change. Anyway, I'd be in favor of changing the documentation on |
It seems Godot is correct in it's use of vector "projection", and while "rejection" seems the correct term for what I want "slide" is clearer once I know what it is.
would only confuse me more, lol. I can confirm that these three methods produce the same result:
So, I would agree that adding mention of projection in the Vector3.slide() documentation would be helpful. |
I've opened an issue on the document git here: godotengine/godot-docs#8286 Therefore I'll close this issue and move on to editing the documentation. |
Describe the project you are working on
I'm new to Godot, but I'm immediately missing a project on plane method for Vector3's. This is easy enough to implement in GdScript but I think it should be a core Vector3 method.
Ie:
I'm willing to make the code changes, but I've also never written C++ code before this and have never tried to build and test the engine. Consider this a work in progress, needing some mentoring.
Describe the problem or limitation you are having in your project
No limitation really, more a quality of life thing.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
I'd like to be able to write:
var projected_vector = my_vector.project_on_plane(surface_normal)
This would keep all the calculation on the C++ side, improving performance (I assume)
It would also help newcomers to vector math. Instead of needing to understand the calculations they can move on with the vector they needed.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
GdScript: (tested)
C++: (I think)
If this enhancement will not be used often, can it be worked around with a few lines of script?
I'm surprised that this does not exist. But I'm also completely unaware of how often this might get used, I only know this was a core method for Vector3 in Unity, and that I liked it :-)
Is there a reason why this should be core and not an add-on in the asset library?
I guess it could be an addon but that kinda keeps it from helping newcomers.
The text was updated successfully, but these errors were encountered: