I have a problem with the character controller and having it interacting triggers.
The problem occurs when we reach high velocities, but to give a better background to what is happening and what our problem is, I’ll explain a little about how we the game mechanics.
The game I am working on is a really fast phased game, where we still try to imitate a physically correct behavior of a character through the PhysX Character Controller. That means that we are storing and using a velocity vector, and we are updating and moving the player with this velocity. In many cases we make a lot of dissension deepening on the current state of this velocity. In this text I will mainly try to focus on one of them, in an attempt to make it easier too follow.
The character can at any time attempt to interact with walls. Deepening on the current velocity, and direction of the character (the direction it is looking) different interactions will occur.
Basically we have three types of wall interactions; Vertical Wall Run, Horizontal Wall Run and a state we call Wall Sticky (essentially grabs on to the wall ad slide downwards for a moment).
Exactly how the different interactions is determined is not important for this context, but what is important is that we need the velocity of the character to translate in to the interaction, like for an example, when hitting the wall in high speed straight on for a vertical wall run, we want to give the character a boosted speed upwards (the character can use the velocity and turn it into upwards momentum).
One more important aspect is that not ALL walls in the game is valid for these kind of interactions (most of them are though, if they are in an appropriate size), and how we distinguishes these walls is through placing triggers in front of them, covering the surface and some space in front of it (Most environmental interactions in the game follow the same principle, and use triggers to in for characters about the functions of their surroundings).
Image from our level editor showing the triggers for a small sample box level i built for this demonstration:
Green transparent boxes indicate walls, read boxes indicate high edges, and yellow indicates low edges (simplified explication). The visible icons is placed in the center of the triggers and used for selection and manipulation in the editor.
Upon hitting walls that is “not intractable”, the velocity is adjusted through a “standard bounce” with low retention (though in high speed the character can bounce out from the wall noticeably).
Here in lies our problem. We are updating the player in a constant 60 FPS, no matter what rate the physics scene is updated in. This is for having a guaranty that the player always behaves the same no matter what. All jumps and all dashes, everything needs to behave in the same way ALWAYS. We can’t accept this varying because of a frame rate drop and the errors in nonlinear Euler interpolations. Thus, the player can sometimes run more than one update at the same time as the PhysX scene runes one.
The real problem is that the Character Controller does not interact with or detect triggers, thus the player can sometimes get a delayed interaction with the trigger, or not detect it at all in high speed.
When this occurs with the wall interactions, the character will not know that the wall is intractable upon colliding with it, thus modifying the velocity for a normal bounce, and thus loosing important information before the actual wall interaction test occurs later (if the character did not bounce out of the trigger before the physics scene get a chance to detect it).
[b]We have two, maybe three ways of going about to solve this, but none of them seam any good.
I know this is a lot of text and that my English can be hard to follow at times. But is there anybody who has had a similar problem, or has a suggestion for a solution?[/b]
It might be worth mentioning we are using the 2.8.4 version of PhysX because the game were well on its way before the update were released and we for the moment don’t have the resources to change the version mid development. If these problems are resolved in a newer version of PhysX and you know this for a fact, please let us know! We have looked in to the newer version but could not find that it included any such fixes.
Any feedback is greatly appreciated!