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

Add an example / best practices for climbing (ladder / ivy) #54

Open
ethereumdegen opened this issue Jul 22, 2024 · 10 comments
Open

Add an example / best practices for climbing (ladder / ivy) #54

ethereumdegen opened this issue Jul 22, 2024 · 10 comments

Comments

@ethereumdegen
Copy link

Add an example / best practices for climbing (ladder / ivy)

@idanarye
Copy link
Owner

It's not supported yet (though I do plan to support it). One could hack it with a custom Basis/Action, of course, but they'd pretty much be implementing the whole thing from scratch, which is not something I want to put in an official example.

Once I support the feature I'll create an example.

@ethereumdegen
Copy link
Author

ethereumdegen commented Jul 23, 2024

I am trying to implement this custom Climbing basis myself (forking the Walk one), and i also want to implement NoClip flying like in SourceEngine games.

However, to do this, I would like my custom basis to be able to have a trait that lets me turn off collision and turn off gravity some how for this particular entity while they are in that basis. This would be nice for Swimming too. Does that make sense? How can i do that? (is there a hacky work around for now ?)

@ethereumdegen
Copy link
Author

ethereumdegen commented Jul 23, 2024

Okay i realized i can use Avian3d GravityScale component to do the gravity scaling. However how can I

  1. control VELOCITY of climbing a ladder, not only acceleration as it seems i can only do now in the basis?
  2. disable collision for my character while i am climbing the ladder? (or otherwise lock all XZ direction movement no matter what i collide with ?)

@ethereumdegen
Copy link
Author

Oh i think i can use LinearDamping and LockedAxes ... will report back :P

@ethereumdegen
Copy link
Author

YAY! I was able to implement climbing by hacking up the Walk basis to contain very very little (like 10% of what it used to contain) and then by using GravityScale =0, LinearDamping = 5.0, and LockedAxes (all locked except for Y axis movement) and it is Source engine like ladder movement :D

Kind of interesting that i have to use a mixture of avian and tnua code here to accomplish this but its actually very clean and nice overall

@idanarye
Copy link
Owner

TnuaVelChange (which TnuaMotor uses for both linear and angular movement) has both boost and acceleration fields. You can use boost to cancel existing velocity and acceleration to offset the gravity - and then add on top of that the boost and/or acceleration you actually want the character to have.

As for determining what you need to cancel - TnuaBasisContext (which you get as a parameter in apply) has a tracker field with that information.

@ethereumdegen
Copy link
Author

ahh okay. I think it is a bit weird that i have to cancel out gravity in the basis code and that it is automatically applied. Since i am making a NoClip basis and Floating basis and Swimming basis, it is super annoying to have to deal with the fact that gravity is implicitly applied and then having to cancel it out. I would rather gravity NOT be implicitly applied and then i would just need to apply it myself in the basis that use gravity like Walk and Crouch and what not ... hmm ..

@ethereumdegen
Copy link
Author

ethereumdegen commented Aug 6, 2024

IM trying to counteract gravity like you describe but it isnt working ..

 let grav =  ctx.tracker
                        .gravity ;
 

        let anti_gravity = -1.0  * grav;

        motor.lin =   TnuaVelChange {
            boost: vertical_velocity_boost,
            acceleration: anti_gravity
        } ; //+ upward_impulse;
        

@idanarye
Copy link
Owner

idanarye commented Aug 6, 2024

Weird. I'll have to look into it.

@idanarye
Copy link
Owner

idanarye commented Aug 6, 2024

Since i am making a NoClip basis

Not sure this is possible with just Tnua. A no-clip requires interfering with the physics backend's collision configuration, which Tnua doesn't do. This is part of the root of many of the limitations you encounter - I'm trying to limit the surface area between Tnua and the physics backend, to reduce the effort it requires to support all the different backends.

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

No branches or pull requests

2 participants