I need some advice with kinematic movement to follow bumps

I have this so setting position of car with offsetting the position (the 3rd parameter)
but I see this is tedious because I must to guess the altitude of bump because when the car reaches the bump after few meters there road goes for example 0.5 units down but in other place road is go down for example with 1 unit
and cannot use the dynamic rigidbody, must use kinematic due to the model of city
what is the easier way to achieve moving down and up?

if(this.entity.name.includes('3.9')){
            this.moveCarDown(position, entity, 0.7); // 3.2
        }
if(this.entity.name.includes('3.3')){
            this.moveCarDown(position, entity, 0.7); // 2.6
 }
if(this.entity.name.includes('1.2')){
            this.moveCarDown(position, entity, 0.7); // 0.5
}
if(this.entity.name.includes('1.0')){
            this.moveCarDown(position, entity, 1.6); // -0.4
}

ok so I found a little easier than offsetting
I drive the car for testing and look into position and try to set the position instead of offsetting, example
I drive to -209, 0.5, -788
the y so 0.5 is the most important
so I set this position

setCarPos(pos, entity, y){
        pos.y = y;
        entity.setLocalPosition(pos);

    }

little easier because I dont have error in y like the car is go down too much due to wrong offsetting

Hi @grzesiekmq,

You can easily offset the position of any entity using the translate method:

this.entity.translate(0, 0.3,0);

This will change the position of the entity by 0.3 vertically (Y axis).

2 Likes