Why are objects rotating when in rest state

Why are objects rotating when in rest state

There are two examples when things are rotating when I would expect them not to. Would be great if anyone could help me understand why.

This happens in both, mac and linux 4.2.2 clients

1. Vehicle cameras base rotating when not having linear velocity

Setup
  • VehicleBody3D
    • Node3D
      • Camera3D (script attached)

I’m using Jolt physics engine.

Script for camera
func _physics_process(_delta):
    var target_origin = camera_base.get_global_transform().origin
    var target_vel = camera_base.get_parent().linear_velocity.normalized()
    var target_basis = camera_base.get_parent().transform.basis.x
    var target_rotation = camera_base.get_parent().global_rotation
    var target_angle = target_vel.signed_angle_to(target_basis, Vector3.ZERO)

    print(">>>>>>>>>>")
    print(target_angle)
    print(camera_base.get_parent().global_rotation)
    print(camera_base.global_rotation)
    camera_base.set_global_rotation(Vector3(target_rotation.x, target_rotation.y + target_angle, target_rotation.z))
Expectation

Vehicle should have two vectors, one is the direction vehicle is pointing towards and second is the direction vehicle is moving towards. For example when drifting the directions won’t match so I would like to point the camera in between the two directions.

Reality

When moving or having a linear velocity, all works fine, but the moment the velocity is not there, the object is rotating in global rotation making the camera constantly rotate.

car

The frame is making the rotation appear as if it turns to the side, but believe it, the things is rotating like crazy matching the logs.

PS. please ignoring the unsigned value issue and angle always being to one side.

2. Ragdoll vortex’ing and not ragdoll’ing

Setup

I followed this video but used jolt physics with JoltGeneric6DOFJoint3D. If I setup the joints everything works, but if I remove the joint for left arm weird issue happens.

Expectation

I would expect the arm not linked with a joint to just flop down and remain there.

Reality

The arm seems to be rotating similar to how the vehicle rotates and never comes to a “flopped rest state”.

human

Not sure if the issues have the same cause but if not, please don’t shoot me for asking two unrelated questions in one topic.

1 Like