[SOLVED] Issues with Vehicle Physics + Ammo.js

In my game I have it to where players can spawn a vehicle via a chat command like so: /rc for RaceCar

The problem occurs when spawning multiple vehicles at once. I’ve wrapped my head around the issue being tied to Ammo.js not being able to depict the vehicles from one another.

Below are some GIFs displaying the above behavior:

  1. Vehiclez 1 - Album on Imgur (Multiple Vehicles)

Upon entering either vehicle instance, control of both vehicles are lost and never regained. You can see the vehicles taking input controls, however it no doesn’t move.

  1. Vehiclez 2 - Album on Imgur (1 Vehicle, no movement upon re-entry)

Upon re-entering a single vehicle instance, control of the vehicle is lost and never regained. Again, input controls are working yet the vehicle refuses to move again.

This is the PlayCanvas Example used for the Vehicle Implementation, which is based on PlayCanvas Buggy Example.

Did a quick test of multiple vehicles. Seems to be fine: https://playcanvas.com/editor/scene/1274987

1 Like

Your example works but they should work seperately from each other’s controls, it may be because I have a variable called ‘inVehicle’ which depicts if the player is in the vehicle or not.

I believe the value passed here is passed to the other vehicle.js scripts, I need to make changes to were it works independently.

The cars are spawned from a template ID.

Yeah, I just used the default vehicle controls scripts that listens for keypresses so the same keys control both.

I’ve just updated it so that you can select between the two by pressing key 1 or 2 on the keyboard: https://playcanvas.com/editor/scene/1274987

Press either 1 or 2 to start controlling a vehicle.

1 Like

Okay thanks @yaustar, I’ll look over my code again. It may be related to my own variables.