Hello! I’ve been working on my project for quite some time now, and I’ve been struggling with one specific problem ever since I started working on the platforming part of my game.
Since its a third person action game, jumping is frequent, so after some time I realised a little problem.
When my character collides with an object, it doesn’t effect the velocity vector of my character at all - this is not a problem when running around on the ground, but since in mid air my character is much less controlable, it is quite hard to miss this problem.
Basically, let’s say the character collides with an object by jumping forwards it, then loses the contact with it at some point (Rises above it, or moves beyond the corner of the object), the character then continues its movement forward as if it hadn’t hit anything. This is a huge problem, because it makes the platforming incredibly annoying and just not fun at all.
What I’d like is to effect my character’s velocity in the X and Z axes, so upon collision my character would lose some of its velocity in the right axis, and just appear to be sliding along the wall, but after it loses the contact, it should build up the velocity again.
I did find a “Sort of working” solution here:
if (controller.collisionFlags & CollisionFlags.Sides)
{
moveDirection.x = GetComponent(CharacterController).velocity.x;
moveDirection.z = GetComponent(CharacterController).velocity.z;
}
This code by theory works perfectly, and gets the job dune, but unfortunately it occasionally results in some wierd collision errors, which can make the character pass through solid geometry. I’m pretty sure I’m supposed to use normal vectors and create a costum velocity for my character, instead, but I’m not exactly sure how to do this.
Maybe anyone has an idea and is willing to help out?
Thanks!