Need advice about my bump trick

So I implement something to lower or raise car
based on position Y of each trigger collision which are placed dynamically
the data in json looks like this

{
    "bumps": [
    {
        "pos":
        {
            "x": -644.7719116210938,
            "y": 3.1999998092651367,
            "z": -176.37185668945312
        },
        "name": "trigger1"
    },
    {
        "pos":
        {
            "x": -643.83935546875,
            "y": 3.3999996185302734,
            "z": -180.26043701171875
        },
        "name": "trigger2"
    }, ...

but it is hard to set position of trigger precisely, because when I set position of trigger then in some places car raise is proper but in other places the car dives into road or it is a bit high like it looks it is flying over the road
so I try to fix the positions but cant get the expected position easily, I mean if I fix position from place where car dives into road to position where car is placed properly then when I drive I have some weird change it is quickly changing from diving state to state where the car should be,
so I see I must fix position earlier not when the car fully dives into road but when it starts diving into road
so then I have proper raising or lowering of car ( in some places I noticed this, this is ok behaviour, it looks like the car is climbing so what I want in case of raising)
so this is problematic so what to do?
the car has rigidbody kinematic
as far I have 241 triggers the all will be probably 400-500 triggers in the whole track
maybe some ‘outline’ of road or some relative position of road
so then car will be translating on Y axis?
generally the car is going straight, but as far I dont have control over the road, if it is possible so then I can set the car based on the road
I mean to know where the road is lower or higher
so I need some data of changing the pos Y of road so then I can set the car

so try to make the car dynamic and add simpler collision to the road?

It’s been the suggestion that a couple of the forum users (including myself). I would prototype with a new project to see if that would give you the effect you need first before going all in.

1 Like

Maybe you can use a raycast from the bottom of the car to the road and use the method from this project to set the car in the same height / ratation / angle as the road.

https://playcanvas.com/editor/scene/923457

Edit: After thinking about it a bit longer I think this won’t work for a car. Sorry.

Maybe raycast, because I was thinking and the bump trick would not work for all cars even if it would be set precisely but only for one car, why? because every car has different part in height (I mean for one this will work because it wouldn’t hide the bumper in road but for other it would hide)

Sends like you want this: https://www.youtube.com/watch?v=wJT-qnjgp3M

This was done in PlayCanvas and Ammo.js with dynamic physics, vehicle simulation. (there’s a thread on the forums somewhere by the developer).

2 Likes

That is why I think raycast is not a solution for this.

what about this project?

That’s just dynamic object with no suspension etc. This is what you would need instead: https://playcanvas.com/project/338993/overview/space-buggy

1 Like