UPBGE Vehicle Logic Nodes

Could anybody walk me through the process of creating a vehicle controller in UPBGE with logic nodes? I’ve been trying to figure it out all day, but no luck. Here’s where I’m at.

Very sorry for the late reply, but this should help:

You only need to create the vehicle once, probably you’ll want that “On Init”, otherwise you’re creating a new vehicle every frame, the rest of the tree should be working :slight_smile: BUT you’ll need to reset braking and steering values if no steering keys or braking keys are pressed.

This has to do with how the vehicle constraint calculates its steering and braking, once you set a value, it stays there until you reset it - I’ll update the wiki page :+1:

1 Like

Thank you so much for your help! I imagine you’re probably pretty busy developing & stuff, so I appreciate your time. My vehicle logic tree seems to be working now, but I think I probably still made a few mistakes that caused a few minor glitches. For example:
(Listed from biggest problem to smallest problem)

  1. My camera (with a camera actuator) won’t follow behind the car (it goes to 45º). I tried rotating the camera to negate the rotation & that works until the car rotates left (or something) & it resets the camera to a 45º viewing angle. Out of the 4 problems mentioned, this is one would probably negatively affect gameplay the most, so it’s my biggest problem.
  2. The steering gets way less responsive during acceleration (even at low speeds).
  3. The braking makes the car go backwards instead of stopping it (and sometimes rotates when stopping at high speed even though no steering keys are pressed).
  4. The wheels don’t rotate when accelerating.

Here’s a video of the vehicle, you helped me make, in action:

Here’s a screenshot of my logic tree:

If you want, here’s my .blend file to help you diagnose the cause of any of my problems mentioned above:

P.S. I think it’d be extremely helpful to put an example node setup and/or even a demo file for controlling a vehicle in the wiki because vehicles are such an essential part of game development, so making the setup as easy as possible to learn will help game devs save a lot of time.

Again sorry for the long wait, I almost never check this website anymore, but you can reach me via the UPBGE Discord channel more easily :slight_smile:

The things you mentioned seem to be quite normal though, what I tend to do when working with vehicles is to make the steering value dependent on the speed, because when the vehicle is too fast and the steering’s too harsh, the car “drifts” with its front wheels, minimizing the steering effect

For the camera issue, I presume you are using the Camera Actuator? I remember this issue from years back, I can’t really tell you what’s wrong there, my guess is that is has got to do something with the Axis calculations…

Braking should actually not do that, I haven’t seen this yet - I didn’t test your file now, but from looking at your tree (which is a perfect setup by the way) it might be because of the -10 value, try it with a positive one and see if it works :thinking:

The issue with the wheels not rotating is something that I can’t fix, there’s some issue in the vehicle constraint class from the physics module, I created an Issue on GitHub for it some months ago, but I can’t say how much of a UPBGE-related problem that is, it might have to do with the Bullet phyics engine itself :man_shrugging:

About that example, I’ve been trying to finish the nodes for the last 3 weeks, so once that’s done I will get around to creating example files for each game concept :slight_smile:

1 Like