Vehicles - Drive and Fly

This package allows users / players to “enter” a vehicle and drive or fly it around.
It has been developed for the Daystiny/Vicentek 2021 Dream Vacation Game Jam entry
“Dream Co - The Metaverse Experience” and was also tested in Crayland.

This package emulates physical driving in first person view with non physical vehicles.
Please check Dream Co for the list of controls or have a look at vehicleUserScript.

How to install:

  • add vehicleUserScript to the User template
  • add one of the vehicle templates to your GetWorld
  • start preview, interct with the vehicle to enter and have fun

Things to consider:

  • being non physical, the vehicles have no awareness of the ground, in fact they are floating
    on the same Z-coordinate that the entity has been placed initially
  • Except for flying with primary/secondary controls, the Z-coordinate never changes,
  • When flying, the Z-coordinate is increased or decreased, but never below the initial Z-coordinate
  • Vehicles have a trigger to handle on/off-road behavior. The trigger determines, if it is overlapping any voxelmesh with a property isRoad = true. If that is not the case and the vehicle is not configured as offRoad, the maximum speed of the vehicle is reduced
  • Vehicles have another trigger to handle pseudo collisions. By default, every voxelmesh entering the trigger will collide. On this collision, the vehicle can take damage and the movement is inversed and slowd down
  • Vehicles colliding with another vehicle cascade the damage
  • voxelmeshes that should not pseudo collide with a vehicle need to be added to the ignoreEntities attribute of the vehicle
  • If these pseudo collisions should also happen when driving against certain meshes, you have to add the vehicleCrashingEntityScript to that mesh entity
  • you can configure vehicleCrashingEntityScript to make the mesh entity physical on collision with the vehicle, which means it will get a kick and fly away (resets to original position after 60 seconds)
  • if the vehicleCrashingEntityScript is on the same entity as a healthScript, the damage will be forwarded to it, so that vehicles can destroy things or kill players on pseudo collisions
  • you can determine the damage the vehicle receives on crashing with changing the damageFactor:
    0 means the vehicle receives no damage … 1 means the vehicle receives full damage
  • if you want to avoid your vehicle from driving on water, make sure that the voxelmesh for the water is different from your base voxelmesh and add the basevoxelmesh(es) to the terrainEntities attribute of the vehicle

Some Q&A around the design of this package:

  • Why do it this way, why not using physical vehicles? Ever tried to place a physical Jeep or Plane on a voxelmesh?
    They sink into the ground …
  • Why are you working with triggers, not collisions? Collisions only work entities vs. players and physical objects. See answer above
  • Why do roads have to be flat? I wish I found an easy way to determine the pitch and roll rotation of the ground under the
    vehicle, however I haven’t found one until now
  • Why can’t I find code inside the package to drive the vehicle straight forward? Because there is none :stuck_out_tongue:

Some samples:

Feedback:

Please send questions, feedback, feature requests using Crayta Discord discord.gg/crayta @Daystiny
or chat with me on Stadia: Daystiny#1423

4 Likes

This is awesome!

1 Like