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

Godot

5823 readers
20 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.

top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 5 points 1 year ago* (last edited 1 year ago) (1 children)

Note: I think most people in here arent going to click on a reddit link so you may get some more views if you link something like a youtube or piped link instead

You can also link directly to the reddit video using this url https://v.redd.it/o6md1vnuemcb1/DASH_1080.mp4?source=fallback (if you want to set that as the url you can edit the message (click on the three dots, then click edit if youre on web) and then put it into the url box instead of the reddit link)

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

Yeah, I just did that bc there isn't a way to upload videos to lemmy. I appreciate the help to at least get it to show as a video lol

[–] [email protected] 1 points 1 year ago (1 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. :)

[–] [email protected] 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:

[–] [email protected] 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.

load more comments
view more: next ›