Sign in to follow this  

Pushing a PhysX Character Controller

This topic is 2654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a 2.5D side scrolling platformer where the character is moved using a character controller.

The issue I am having is with implementing an elevator/moving platform. The platform is a normal PhysX object that is moved by setting its linear velocity. I want to have it so that the player can jump onto this platform and ride it.

The character controller rides the platform down as it is just continuously falling onto it but as soon as the platform moves up the character controller just falls through it. It also tends to not detect the collision on the platform if the platform is moving upwards so the character just falls through it.

The only way I've gotten it to work sometimes (but pretty glitchally) is through setting a bool in a collision response class to say the controller is on the platform then when it comes to move the controller I check this bool and if true grab the current velocity of the platform and add it onto the velocity of the character controller before calling the "move" function. This doesn't work most of the time and when it does the player is never truly on the platform and is usually floating halfway through it.

This seems to be too much of a hacky way to do it but I can't seem to find an official method to having the character controller on a moving object.

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
The problem is you can't push NxControllers (unless I am mistaken, its been a while since I've used PhysX). One solution is to make your own controller where by you allow it to be pushed by certain things (the platform). Another option is maybe to spawn a dummy actor when the player is on the platform make it such that it collides with nothing except the platform. That dummy is then going to move correctly as if it were on the platform. Each update set the players position to that of the dummy and then add any movement (ignoring gravity as the dummy will take care of that) and move the dummy accordingly.

You've still got the problem of detecting and syncing. I would put a trigger volume above the platform (rather than detecting a collision with the platform itself). Idea being you have a volume right above the platform (that moves with it) where you can get an OnEnter/OnExit event being fired. You can listen for that and then spawn the dummy where the player is and begin syncronising the positions using a process (which are really brilliant for things like this as they keep your code clean). The OnExit should kill the process/dummy actor (or disable it for later reuse).

Not sure how you'd go about creating the trigger volume though :/ (it needs to detect collisions but let things pass into it and also detect when things leave it).

Share this post


Link to post
Share on other sites
Thanks Nanoha, that sounds like a workable idea. We've already got triggers set up in our game so I should be able to use that for the spawning on the platform.

I have the platform working a bit smoother with the method I'm currently using but it doesn't like high frame rates as the NxController just slips through so I'll probably give your dummy actor idea a shot.

Share this post


Link to post
Share on other sites

This topic is 2654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this