Need help with aligning player rotation to ground normal

CODE

if (Is_Walking == true && skidding == false || Is_Airborn_Moving == true && is_WallClimbing == false && skidding == false || is_WallSliding_L == true || is_WallSliding_R == true)
{

 // Vector2 boing = new Vector2(inputvec.y, inputvec.x);
 // Vector2 boing_rotated = boing.Rotated( Camera_Pivot.Rotation.y).Normalized();
 // GD.Print(Mathf.Lerp(skeleton.Rotation.y, Mathf.Atan2(-direction.x, -direction.z), 0.5f));

 float Next_NextRotation = Mathf.LerpAngle(skeleton.Rotation.y, Mathf.Atan2(direction.x, direction.z), Turn_Speed);


 System.Numerics.Quaternion Next_Ground_rotation = System.Numerics.Quaternion.CreateFromAxisAngle(new System.Numerics.Vector3(Ground_Normal.x, Ground_Normal.y, Ground_Normal.z), NextRotation);
 
 skeleton.Rotation = new Vector3( Next_Ground_rotation.X, Next_NextRotation, Next_Ground_rotation.Z);


 
 // skeleton.Rotation = skeleton.Rotation.Normalized();

}

Question

Trying to align player with ground normal and I need help with it. I’ve been stuck on trying to do this thing for months now and I really need help. ignore the comented code I know it looks goofy lol.

https://kidscancode.org/godot_recipes/4.x/3d/3d_align_surface/index.html

1 Like

I converted that script into C# and got an error this is my code

private Basis _bruh(Basis basis, Vector3 normal)
{

  basis.x = -basis.z.Cross(normal);
  basis.y = normal;
 


  basis = basis.Orthonormalized();
  return basis;

}

public override void _Process(float delta)
{
if (Ground_Cast.IsColliding() == true)
{
Ground_Normal = Ground_Cast.GetCollisionNormal();
Plr_Model.GlobalTransform = _bruh(Plr_Model.GlobalTransform, Ground_Normal);
}

}

the error say’s " C:\Users\User\Documents\FP_Prototype\Lilac.cs(47,47): Argument 1: cannot convert from ‘Godot.Transform’ to ‘Godot.Basis’ "

You are returning a basis from _bruh and passing basis in as a parameter.

So it should be GlobalTransform.Basis = _bruh(Plr_Model.GlobalTransform.Basis, Ground_Normal)

I did that aswell but a new error popped up and said " C:\Users\User\Documents\FP_Prototype\Lilac.cs(49,40): Cannot implicitly convert type ‘Godot.Basis’ to ‘Godot.Transform’ "

…bruh. on god. just like that. fr?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.