Saturday, October 5, 2024
spot_img

Incorrect steering management of the car – Cocos Creator


:sunrise_over_mountains:

race3dCopy.zip (8.3 MB) (solely instance, little or no code)

The Challenge:

  • Urgent “left” leads to targetOrientation = -30, however the automotive turns proper.
  • Urgent “proper” leads to targetOrientation = 30, and the automotive turns proper.

Assist me perceive the issue.



    setSteeringAngle(steeringDelta: quantity) {
        this.automotive.hubNode.forEach(hub => {
            let z = 0;
            if (hub.identify == "1left" || hub.identify == "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)
            }
        });
        
    }
 


    replace(dt: quantity) {
        
        if(this.key_status.left){
            this.setSteeringAngle(30);
       }

       if(this.key_status.proper){
           
            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);
        }


    }

element ConfigurableConstraint

image
May you please affirm that the image wheels is the left orientation wheels you need?



1 Like

Sure, that is precisely what I would like. ( I’m setting up a automotive )


You’ll be able to change the Physics Sytem to PhysX, then you’ll be able to change the automotive path left or proper as you need.



1 Like

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles