Ultimate Vehicle Script | Sansar Store
Ultimate Vehicle Script

Ultimate Vehicle Script

 250

You need to own this item to leave a rating.

0 ratings

Ultimate Vehicle Script v1.61

OVERVIEW
========

This is a intermediate level vehicle script, you can make an animated mesh vehicle drivable with vehicle like physics via the WASD/arrow keys when sitting in it. It can also optionally animate to the speed the vehicle is moving. You will need to make the scene object set to dynamic motion type, mark the mesh as 'IsScriptable', and enable 'Moveable by Script'; You will also need to add a sitpoint to it for the driver -- extra passenger sitpoints can be added by adding bones/collision shapes to the mesh in your 3d editor.

If you want headlights or breaklights, add them to the vehicle object and set their IsScriptable to true/on. Slot them in the list for each on the vehicle script (copy/paste references to each!), and choose your headlight colors/settings etc. The '1' key (not numpad) on keyboard toggles headlights on and off.

The '2' key (not numpad), toggles a HintText overlay that shows that vehicles gear and speed (velocity, not mph/kph) stats in an overlay when driving the vehicle at runtime.

You must add an AudioComponent/emitter to the vehicle object as well as select your engine and horn sound on the script properties for the vehicles sound system to work

A few tips & tricks:

1) If you want tighter acceleration when taking off, add more gears by increasing the MaxGear value. Then move the gears closer together by lowering the ShiftIntervalSeconds amount to something like 0.1 or 0.5

2) If the vehicle 'hops around' after landing from a jump, set the UngroundedCooldown to a way lower value.

3) If the vehicles do not get enough air when jumping ramps etc, set the VehicleGravity property to a lower value, lowering the vehicles volume's Mass and Friction volume settings can also help with this, each way will give a slightly different effect.

4) If the vehicle doesn't move at all, it is probably because of the vehicle size.. you will need to adjust the GroundDistance setting; Some guidelines for its value: A normal sized bike, vehicle or helicopter should have it set to around 0.5; If it doesn't work, try lowering it to around 0.25; It is the distance expected between the center point of the vehicle object to the ground and needs to be set correctly for grounding to function correctly; For a giant bus, we had to set it to 1.5; In most cases 0.25 or 0.5 will do just fine;

5) Add an extra sphere collider to each wheel area to be able to drive over non-flat terrains

PROPERTIES
==========

It has many options and settings allowing you to somewhat customize the way the vehicle moves and handles. Listed below, are all of the descriptions/tooltips for each property on the script that explain what each is for:


'DebugMode': When enabled, some log entries will be created for basic debugging, this is not a highly verbose type of debugging Default: false

'ShowOverlayOnDrive': When enabled, the Gear and Speed overlay (uses HintText) will be shown when the driver is driving the car. When disabled, it must be toggled on/off manually using the '2' key (not numpad); Default: false

'AnimationComponent': Optional, you can slot in the AnimationComponent of the vehicle here -- and the mesh animation will play based on the speed the vehicle is moving (velocity)

'RigidBody': Optional, you can slot in the main volume of this vehicle. If nothing is slotted in here, it will be expected that the vehicle volume is part of the same object this script is on.

'SitpointRigidBody': Optional, you can slot in the volume that your SitPoint is in here, might be useful if the SitPoint is part of a different object than the actual vehicle (ex: remote controlling)

'Headlights': Slot in your headlight LightComponents for this vehicle here

'HeadlightsIntensity': The intensity of the headlights when they are turned on; Default: 40f

'HeadlightsColor': The color to set all of the headlights to when in use (required due to an limitation with GetNormalizedColor() in the ScriptAPI); Default: 1f,1f,1f,1f

'AutoHeadlightMode': When enabled, headlights will be turned on when a driver drives the vehicle, and turned off when they exit. When disabled, the '1' (not numpad) toggles them on and off; Default: true

'HeadlightsStartEnabled': When enabled, the headlights will be on for this vehicle when the experience starts; Default: true

'Breaklights': Slot in your breaklight LightComponents for this vehicle here

'BreaklightsColor': The color to set all of the break lights to when in use (required due to an limitation with GetNormalizedColor() in the ScriptAPI); Default: 1f,0f,0f,1f

'BreaklightsIntensity': The intensity to set all of the breaklight LightComponents (if slotted in), when in use, when not in use they will be set to 0"; Default: 20f

'BreaklightThreshold': The speed threshold (in total velocity), that if the vehicles speed is below it, the brake lights (if slotted in) will be turned on"; Default: 1.0f

'FireEvent': Send this event when the player presses the 0 numpad key, useful for triggering a dispenser script also on the vehicle object etc"

'EnableEvent': Listen for this event, when received the vehicle will become enabled -- StartEnabled is the starting value when the scene starts

'DisableEvent': Listen for this event, when received the vehicle will become disabled -- StartEnabled is the starting value when the scene starts

'SitEvent': The event to send when the driver sits to start the vehicle

'StandEvent': The event to send when the driver stands/exits the vehicle

'Group': The group to use for the available events defined above

'UseVehicleIndicator' - When enabled, a seperate mesh can by made visible for the person driving it. Ex: child an arrow mesh into the vehicle, and slot it in below via VehicleIndicatorMesh

'SyncIndicatorPosition' - When enabled, the vehicle indicator will additionally sync to the world position of the vehicle in realtime (helpful for remote controlled car setups, so each player knows which car they are driving from far away)

'IndicatorPositionOffset' - The offset position from the vehicle for the indicator mesh

'VehicleIndicatorMesh' - The mesh of the vehicle indicator (copy+paste reference please), made visible only for the player that is driving this vehicle, and hidden when they exit the vehicle

'HidePlayerOnDrive': When enabled, the avatar will be come invisible while driving this vehicle, and returned to visible when exiting the vehicle; Default: false

'GroundDistance': The distance expected from the vertical center of the vehicle to the ground, set this to around 0.2 for a medium sized bike, or maybe 0.5 for a helicopter, or 1.5 for a bus which is up much higher than the others; Default: 0.5f

'UngroundedCooldown': The amount of time (in seconds) before the vehicle is allowed to accelerate again after becoming grounded again (ex: landing from a jump); Default: 0.25f

'LinearDamping': Linear damping, set to a lower number (ex: 0.2) to make the vehicle take longer to come to a complete stop, or a higher number to make it feel more tight and abrupt when the user stops giving it input; Default: 1.0f

'AngularDamping': Angular damping, set to a lower number to allow more flipping/rotations/etc, or a higher number to make turning and going over ramps less rotational; Default: 5.0f

'VehicleGravity': The gravity value this vehicle will have at runtime; Default: 9.81f

'AllowFlying': When enabled, the vehicle will be able to fly -- normal WASD/arrow control will be available, additionally the 5 and 0 numpad key allow moving vertically; Default: false

'CenterOfMass': Sets the center of mass rigidbody property for this vehicle, useful to make a vehicle not able to be 'knocked over' or 'tip over upside down' etc; Default: 0f,0f,-0.25f

'TransResetSeconds': The amount of time that can pass after the user stops accelerating, before the automatic transmission drops back down to the first gear; Default: 0.75

'ShiftIntervalSeconds': The amount of time that the transmission uses each gear for before moving up to the next one; Default: 3.0

'MaxGear': The number of gears the vehicles transmission has total; Default: 12

'GearHP': The additional amount of horsepower applied to the vehicle acceleration per gear; Default: 1.0f

'ReverseUpSpeedFactor': The speed factor the vehicle goes in reverse (and up when flying mode is enabled), compared to forward, 0.1 would mean 10% of the speed of going forward, 1.0 would equal the same or 100% of the forward speed. Why? Because realistic cars generally do not backup at fullspeed :) Default: 0.5f

'EngineInterval': The speed of the vehicles engine loop, it is advised not to change this value; Default: 0.02

'Turning Speed': The speed that the vehicle turns left and right when moving; Default: 0.075f

'ForwardVectorCorrection': When enabled, prevents the vehicles forward direction from getting messed up -- only enable this if you see it happening in your use case (it may not be needed), disabling this will make collisions with dynamic objects look better and less glitchy; Default: false

'ResetOffset': When the user presses the 'R' key, it will reset their orientation to its original orientation, and for position it will apply this offset too; Default: 0f,0f,1f

'EngineSound': The base sound resource to play as the engine sound, based on vehicle's current velocity when active

'HornSound': The sound that plays when the driver pressed the numpad enter key

'Max EngineSound Speed': The ceiling of the amount of pitching up of the EngineSound based on speed of vehicles movement; Default: 25.0f

'EngineSound Factor': How much to pitch up the EngineSound based on speed of vehicles movement overall; Default: 1.0f

NOTES
=====

* This vehicle script does not yet support VR controls yet, but as soon as the ScriptAPI supports it, will be updated

* Support & forum on discord: https://discord.gg/gUfP23A2aC

Item name
UltimateVehicleScript.v1.61
Min. resale price
100