Skip to content
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

Fixed issue where Projectile would spawn at world orgin instead of bullet_point in Godot 4.3 #285

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

JohnnyThunder2
Copy link
Contributor

Hi... first Pull Request ever, figured I would just fix the issue before I brought it up.

I'm on Arch Linux running Godot 4.3, so possibly this is just an issue I'm having but, for some reason the Toy Pistol wieldable would only spawn projectiles at the world origin instead of the bullet_point origin of the player. After adding these two lines of code (Sorry if they are a mess, I'm a novice programmer) it fixed the issue and the Toy Pistol now works as it should.

Line 46 doesn't really do anything, but while I was troubleshooting, I insured the default value was set correctly. Don't believe that line needs to be added.

@Phazorknight
Copy link
Owner

Hey, thanks for this! Will take a look but looks like this should be 4.2 compatible.
If you're using COGITO with 4.3, would you mind sharing your experience in the discussion here: #247

Would be curios if there are any issues you ran into (besides this one 😅 )

@JohnnyThunder2
Copy link
Contributor Author

Oh yeah... I'm running into issues... this and one other big one that has to do with the way the guns display, it mostly just works, but I'll detail them over there as best I can.

I didn't even mean to upgrade to 4.3, I'm just new and using Godot and thought "Yeah, it's fine, I'll just use the Arch repo what could go wrong?" and here I am trying to upgrade your repo to work with 4.3, lol...

...I've learned over the years having been on Linux for so long now, it's best to not complain and just fix everything yourself if you can until you're 100% sure you're totally lost. So I didn't wanna file any bug reports until I fixed them like this one.

@Phazorknight
Copy link
Owner

@JohnnyThunder2 I've commented out one line. For me this one caused the projectiles to be spawned facing sideways / wrong direction. Let me know if this changes the behavior much on your end.

If not, I'm happy to merge this in.

@JohnnyThunder2
Copy link
Contributor Author

JohnnyThunder2 commented Sep 22, 2024

OK, I have some weird bug. If I comment that line of code out and shoot along the Z axis, the bullet shoots straight, if I turn and shoot along the X-axis the bullet shoots sideways.

I added that line of code and it seems to work correctly for me...

I'm wondering if this is a Godot bug between the Linux and windows build? Need to investigate more.

Edit: You know, I doubt that's the case... I'm probably just doing something wrong... need to study more.

@JohnnyThunder2
Copy link
Contributor Author

Yup, yup... I'm a total noob. I rotated the bullet_point 90 degrees in the y axis and forgot I had done so...

Thank goodness, I was just about to dive deep into trying to use Grep to figure out where the global_transform.basis method were in the source code of Godot... lol... OK... will try and figure it out when I can.

@Phazorknight
Copy link
Owner

Phazorknight commented Sep 22, 2024

Ooooh, that explains it.
Well, i've rotated the bullet point node and commented the line back in, so this should hopefully now work as intended.

@JohnnyThunder2
Copy link
Contributor Author

Oh do you wanna do it like that? I fixed the solution in code by changing that line to:

Projectile.global_transform.basis = bullet_point.global_transform.basis * Basis(Vector3(0,1,0), deg_to_rad(-90))

This code isn't all that efficient I imagine, but you can keep the transform of the bullet_point if you want using this solution. Whatever you wanna do, you're the boss!

This was fun, thanks!

@Phazorknight Phazorknight reopened this Sep 23, 2024
@Phazorknight
Copy link
Owner

I saw you closed this PR. I've re-opened this so it can potentially merged into main.

Oh do you wanna do it like that? I fixed the solution in code by changing that line to:
Projectile.global_transform.basis = bullet_point.global_transform.basis * Basis(Vector3(0,1,0), deg_to_rad(-90))

I'd rather not rotate a node in code as it would obfuscate what devs would see/edit in the editor. Having it just take the transform as-is makes it easier for devs to edit/tweak the bullet_point as needed.

@JohnnyThunder2
Copy link
Contributor Author

I'm a bit confused how Github Pull requests work... by updating the code on my repo, did that effect the main repo? I thought you had merged the previous code and everything was good? Do I need to change it back?

Fixed an issue where the Toy Guns bullet would not spawn correctly.
@Phazorknight
Copy link
Owner

I'm a bit confused how Github Pull requests work... by updating the code on my repo, did that effect the main repo? I thought you had merged the previous code and everything was good? Do I need to change it back?

A PR is kinda like a temporary branch that can be pushed to. Nothing gets pushed to the Cogito main branch unless collaborators approve and merge it in. When a PR gets merged, it usually also gets closed.

From what I can tell, you closed the PR again, and you've force-pushed from the most recent main branch. If the person who opened the PR close it, it's usually assumed that the changes are no longer needed or shouldn't be merged into main for some reason.

I'd still like to update the projectile stuff to future-proof it for Godot 4.3.
If you could undo/adapt this line to not rotate the bullet_point:

Projectile.global_transform.basis = bullet_point.global_transform.basis * Basis(Vector3(0,1,0), deg_to_rad(-90))

instead just matching the transform and rotate the bullet_point node in the editor as needed, then we should be back to before the force-push happened. I'll give it another review then. If this gets merged, using this procedure also makes sure you are credited as contributor to the main branch.

Changed the Transform of the bullet_)point to be -90 in the Y so the projectile will spawn correctly.
@JohnnyThunder2
Copy link
Contributor Author

JohnnyThunder2 commented Sep 23, 2024

OK I changed it back on my branch... I'm really sorry for the confusion, this is my first time using Github to do a pull request so I'm not sure how everything works still.

Edit: OK I get it now... if I update the code on my branch, it automatically closes the pull request over here. Reopened the pull request with the required changes.

Copy link
Owner

@Phazorknight Phazorknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, thanks! Approved.

@Phazorknight Phazorknight merged commit 7c65954 into Phazorknight:main Sep 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants