Incorrect steering control of the vehicle

:sunrise_over_mountains:

race3dCopy.zip (8.3 MB) (only example, very little code)

The Issue:

  • Pressing “left” results in targetOrientation = -30, but the car turns right.
  • Pressing “right” results in targetOrientation = 30, and the car turns right.

Help me understand the problem.



    setSteeringAngle(steeringDelta: number) {
        this.car.hubNode.forEach(hub => {
            let z = 0;
            if (hub.name == "1left" || hub.name == "1right") {

                let smoothedSteeringAngle = hub.getComponent(ConfigurableConstraint).angularDriverSettings.targetOrientation.z;
                z = math.lerp(smoothedSteeringAngle, steeringDelta, 0.08);
                let com0 = hub.getComponent(ConfigurableConstraint);
               
                com0.angularDriverSettings.targetOrientation = new Vec3(com0.angularDriverSettings.targetOrientation.x, com0.angularDriverSettings.targetOrientation.y, z);
                
                
                console.log(com0.angularDriverSettings.targetOrientation)
            }
        });
        
    }
 


    update(dt: number) {
        
        if(this.key_status.left){
            this.setSteeringAngle(30);
       }

       if(this.key_status.right){
           
            this.setSteeringAngle(-30);
       }

       if(this.key_status.gearUp){
        
            this.setDrivingSpeed(100);
            this.setDrivingForce(500);
       }
       if(this.key_status.gearDown){
        
        this.setDrivingSpeed(-100);
        this.setDrivingForce(500);
        }


    }

component ConfigurableConstraint


image
Could you please confirm that the picture wheels is the left orientation wheels you want?

1 Like

Yes, this is exactly what I need. ( I am constructing a car )


You can change the Physics Sytem to PhysX, then you can change the car direction left or right as you want.

1 Like


FYI

1 Like