@YoSoyFreeman hope you don't mind a random question?
I've been playing with Godot and implemented your mouse aim tutorial (which works brilliantly!), and I'm trying to add movement keys for a fly cam. I've got some basics working and I can fly up and down with jump/crouch, and left/right/forward/back in the X/Z plane, but I was hoping to get it to fly forward along the head direction.
Currently I'm essentially doing dir * character basis, but not sure how to get the head rotation involved!
=> More informations about this toot | More toots from PossiblyMax@hachyderm.io
@PossiblyMax
Give me some time and i will make you a full example before tonight!
=> More informations about this toot | More toots from YoSoyFreeman@mastodon.gamedev.place
@YoSoyFreeman Oh that would be awesome, maybe something else for the blog? I had a look to see if you had already done it there 😅
Thanks so much!
=> More informations about this toot | More toots from PossiblyMax@hachyderm.io
@PossiblyMax
Maybe! yeah, there is nothing more, this was my first article!
just for clarification, you want something like the built in editor camera, right?
Move in reference to where you are looking and global up and down, right?
=> More informations about this toot | More toots from YoSoyFreeman@mastodon.gamedev.place
@YoSoyFreeman Yes just like the camera in the editor 👍. Essentially 'if I'm looking at something, forward will move me towards it, back will move away, up will move me 'up' as I'm looking (rather than straight up the Y)'.
So not the global up and down, the 'based on looking' up and down, if that makes sense?
=> More informations about this toot | More toots from PossiblyMax@hachyderm.io
@PossiblyMax
Perfect! i will tell you when it is ready, please share with me in private an email to send it to you later!
=> More informations about this toot | More toots from YoSoyFreeman@mastodon.gamedev.place
@PossiblyMax
I'm almost ready with it. There are like 15 lines of code without counting comments, so i will pass you an screenshot of the code!
=> More informations about this toot | More toots from YoSoyFreeman@mastodon.gamedev.place
@PossiblyMax
Hi Max! Here you have it! Just put the following code into the character physics process.
Let me explain why it didn't work as you wanted: As you may remember, why are NOT rotating the character to look up and down, that would cause all kind of collision issues. Because of that, we only rotate the camera vertically. This means your character basis is not the one you want for this, but your camera basis. A few exports and it's done. Hope it is useful for you!
=> View attached media | View attached media
=> More informations about this toot | More toots from YoSoyFreeman@mastodon.gamedev.place
@YoSoyFreeman Aha that works perfectly, wow I was actually pretty close - switching to the camera (only) worked mostly but I adapted the rest of your code over too as it is nice and easy to understand.
I knew using the character basis was incorrect and the head basis too, but I didn't even think about using the camera directly 🤦
Mine is in a separate script like AimLook, so I had to export a character to set the velocity on too - I might change it though 😁
Thanks so much for your help!
=> More informations about this toot | More toots from PossiblyMax@hachyderm.io
@PossiblyMax
Thank you so much Max! I'm very glad it helped you! I try to provide very readable code, i think it helps to visualize what is actually happening! So happy you found my solution good!
Don't hesitate to ask any future questions!
=> More informations about this toot | More toots from YoSoyFreeman@mastodon.gamedev.place This content has been proxied by September (ba2dc).Proxy Information
text/gemini