this post was submitted on 18 Jul 2023
16 points (100.0% liked)

Godot

5918 readers
22 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

[email protected]

Credits

founded 1 year ago
MODERATORS
 

I'm making a game that takes heavy inspiration from Zelda games like Ocarina of Time, Wind Waker, and Twlight princess, i.e. OoT-lineage Zelda as opposed to BotW & TotK and games that stem from Link to the Past. It's not a fan game, of course, but if you like OoT/MM/WW/TP/SS, then you'll (hopefully) like my game.

One central aspect to nail is the camera system these games use. There's some variation, so I've picked one to "clone." I'm basing this camera off of Wind Waker's. It has a default mode where Link runs around the camera with left and right and pushes/pulls the camera with up and down. If you wait long enough, the camera will move to be behind him, and of course there's a Z-targeting mode that will force the camera to move behind him and let him strafe. Finally, there's a free camera mode that works like the camera in a lot of modern third person games.

In terms of movement, there's walking and running, but jumping is relegated to hopping across short gaps in these games, and I've implemented that system as well.

you are viewing a single comment's thread
view the rest of the comments
[–] Feyter 2 points 1 year ago (2 children)

That is some decent camera system you implemented. Looking great so far. Can you give some details about how you set this up?

I remember trying myself on a Zelda Like 3D character controler a long time ago (back when I was still using unity) A very clever thing I learned back then was to project the camera to a sphere collision shape using raycast. On this way it's very easy to implement a smooth rotation and you can easily prevent the camera from clipping through walls and stuff.

Is this what you're doing her as well?

PS: I like that the test pattern texture of your level has so much detail. Not just the same plane checker square over and over again. :)

[–] KindaABigDyl 2 points 1 year ago* (last edited 1 year ago) (1 children)

Is this what you’re doing here as well

Not at all. I don't have wall clipping support set up yet at all! It's a lot more simplistic. I've handled wall clipping in a similar camera system before using a SpringArm, but I don't think that will work here.

What I do here is I have one object that follows just the camera's y rotation, and I use that to get a forward vector using -object.basis.z.normalized() and I set a target position at player_pos + -forward * FOLLOW_DISTANCE + Vector3.UP * FOLLOW_HEIGHT and lerp to there. That handles moving with the player forward and backwards.

Then in the player code, I read the stick input into Vector3(x, 0, y) and then rotate it based on the camera's y rotation to put it into screen coordinates. Then I multiply by MOVE_SPD and set velocity.x & .z to the x and z of the product. This makes the player move forward and back with relation to the camera's forward and back.

However, you move left and right based on the tangent of a circle around the camera because back in the camera code, I have a look_at which causes the camera to turn as the player moves right/left relative to it, causing circular motion.

Beyond that, there are some simple tweaks like a timer that runs before setting a boolean to cause it to rotate back behind the player or only moving if the player is outside of the follow distance. Things like that.

It's pretty tightly coupled, which isn't great from a code perspective, but it's also unlikely to fundamentally change. If that were to happen, I'd probably want to totally rewrite the system anyway.

PS: I like that the test pattern texture of your level has so much detail. Not just the same plane checker square over and over again. :)

I just found it online somewhere years ago lol. Probably opengameart? I no longer have the original source, but it's pretty good for testing:

[–] Feyter 1 points 1 year ago

That sounds a bit fiddly just from reading it but I'm sure it makes totally sense in code. Now that you mentioned it, yes adapting the players forward based on camera view is something I totally forgot here.