This is kind of hard to explain, but i want to code a walljump with a character controller and i want to do this in two steps. For example when i press the Jump button when near a wall, i want the character to have the Same orientation than the wall and then jump out.
Here’s what i’ve done.
void OnControllerColliderHit(ControllerColliderHit hit)
{
if ((Input.GetButtonDown("Jump")) && (_controller.collisionFlags & CollisionFlags.CollidedSides) != 0 && !_grounded)
{
_hitNormal = hit.normal; //Normal of the hit
_wjtimer = 0.0f; //Timer the character is on the wall
_preWJ = true; //Boolean that is pre-walljumping
_walljump = Vector3.Reflect(_velocity, _hitNormal); //Direction the character will jump out after being for 0.5 seconds
_wjwallvector = _hitNormal;
_staticRotation.eulerAngles = _wjwallvector; //Rotation the character will be facing in the wall
_followcamera = false; //The character will stop following the camera
}
}
Basically _wjwallvector is the vector the character will be facing for 0.5 seconds before walljumping, which should be facing the wall that the character was facing when i pressed space.
_walljump is the Direction the character will be pushed out the wall after being in the wall for 0.5 seconds.
Basically my issue here is that i get both vectors WRONG, they always give odd results
For example the _wjwallvector is always facing the same direction no matter what wall i jump to.
and the _walljump vector makes me jump to a odd place too, in short none of them work properly.
TL;DR: I want to get two vectors:
_wjwallvector: Make the character face the wall i jumped to.
_walljump: Make the character jump to the opposite angle i jumped to (Basically a reflected vector).
Is there any way i could get the right values of these two rotations? i would really appreciate it since i’m stuck in this issue and i don’t find a way out