0 votes

Hi there;
i have a 2d focused background and want to dive into 3d :)

i use a KinematicBody with moveandslide for my boat style movement - this is simple and works great. Now i want to rotate the Mesh and CollisionShape to match the rotation of the floor.
Imaging going from a flat surface onto a ramp in a car or a boat. I´ve got a raycast stuck on the belly and get the collision normal and the rotation of the colliders mesh, but i dont get the rotation to be correct.
I suspect i only need two axis of the rotation, because i want to still turn around my local y axis?

these ar some ways i tried it:

#ray method
if ray.is_colliding():
    var collider = ray.get_collider()
    #$CollisionShape.rotation = Vector3(collider.get_parent().get_parent().rotation.x, collider.get_parent().get_parent().rotation.y, collider.get_parent().get_parent().rotation.z)
    # or : 
#$CollisionShape.look_at_from_position($CollisionShape.global_transform.origin, ray.get_collision_normal(), Vector3(0, 1, 0))
    if Input.is_action_just_pressed("ui_select"):
        print("data:")
        print(ray.get_collision_normal())
        print($CollisionShape.rotation)

#collision method
var hitCount = get_slide_count()
if hitCount > 0:
    var collision = get_slide_collision(0)
    if collision.collider is StaticBody:
        $CollisionShape.transform.basis = Basis(-collision.normal)#or
        $CollisionShape.rotate_object_local(Vector3(0, 1, 0), collision.collider.transform)
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.