Ancestors

Toot

Written by Max on 2024-02-05 at 11:37

@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!

=> View attached media

=> More informations about this toot | More toots from PossiblyMax@hachyderm.io

Descendants

Written by Yo Soy Freeman on 2024-02-05 at 11:51

@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

Written by Max on 2024-02-05 at 12:01

@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

Written by Yo Soy Freeman on 2024-02-05 at 12:10

@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

Written by Max on 2024-02-05 at 12:34

@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

Written by Yo Soy Freeman on 2024-02-05 at 12:36

@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

Written by Yo Soy Freeman on 2024-02-05 at 13:10

@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

Written by Yo Soy Freeman on 2024-02-05 at 13:27

@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

Written by Max on 2024-02-05 at 15:38

@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!

=> View attached media

=> More informations about this toot | More toots from PossiblyMax@hachyderm.io

Written by Yo Soy Freeman on 2024-02-05 at 16:17

@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

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/111878669606711169
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
296.534885 milliseconds
Gemini-to-HTML Time
4.328598 milliseconds

This content has been proxied by September (ba2dc).