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

fix character capsule size issue #329

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xx1adfasd
Copy link

@xx1adfasd xx1adfasd commented Aug 9, 2024

In project Foxtrot, the capsule of the fox should be in fact a lying down cylinder.
Because its an quadruped animal.

So in fact in the code the height is the length of the fox, and the radius
is a half of the height of the fox.

Also, the radius of the capsule need to be multiplied by the scale_y.

There's no visual changes in the game.
Open "Foxtrot Dev" window and toggle Colliders rendering on to see the difference.

Also if the pull was merged, I assume that "HEIGHT" should be renamed to "LENGTH" later on.

In project Foxtrot, the capsule of the fox should be in fact a lying down cylinder.
Because its an quadruped animal.

So in fact in the code the height is the length of the fox, and the radius
is a half of the height of the fox.

Also, the radius of the capsule need to be multiplied by the scale_y.
In project Foxtrot, the capsule of the fox should be in fact a lying down cylinder.
Because its an quadruped animal.

So in fact in the code the height is the length of the fox, and the radius
is a half of the height of the fox.

Also, the radius of the capsule need to be multiplied by the scale_y.
@janhohenheim
Copy link
Owner

You are of course correct. I intentionally use a capsule here because I expect most users to want a humanoid character. The fox is more of a placeholder. I see two possibilities:

  • Merge this PR with a comment guiding a user to capsules for bipeds.
  • Change this PR to instead say in a comment how one could use a laying collider for a quadruped.

Not sure what the best course of action is. I'm leading a bit towards the latter right now, but I'll have to think about it.

@xx1adfasd
Copy link
Author

xx1adfasd commented Aug 10, 2024

After some thinking, I think the best we can do here, as a template project should do, is to support every cases.

Suppose someone want to make a game with a human AND a fox, like the fox being his pet etc. Then there's need for character capsule for both humanoid and quadruped characters.

So, we can basically make an enum to mark which kind of model did our model use, then past it into CharacterControllerBundle.

And also Global number HEIGHT and RADIUS will then not be the best way. We can then write the number in the game setting file, like what we currently did in assets/config/config.game.toml

enum CharacterCapsuleKind{
    X, // lying, the head is facing X
    Y, // upward, like a human
    Z // lying, the head is facing Z
}

//...
let z_kind = CharacterCapsuleKind::Z;
let fox_bundle = CharacterControllerBundle::new(z_kind, height, radius)

and the code of new will handle the FloatHeight assignment work (if lying, radius*scale_y is the FloatHeight, if Y upward, the capsule_height*scale_y is FloatHeight and capsule_height = body_height - 2 * radius (remember the height we passed in is half height of the capsule, and the capsule_height is the length of the cylinder without the two half spheres ))

By the way, if this method is adopted, we then maybe in fact actually put a human model in the game as a showcase. I think the mixamo Robot is good to go. (Imagine a Robot NPC who can talk to the fox to give some information)

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