1. The space forums use a separate registration system from the main virtual world. To comment on these forums, you need to create a separate forum account.
    Dismiss Notice
  2. Hey there, if you want some direct help without hopping inworld - try our Discord channel at https://discord.gg/mptfycQ
    Dismiss Notice

Super Quick Tutorial & Docs - Using Modular Vehicles

Discussion in 'General' started by Adam, Aug 4, 2017.

Share This Page

  1. Adam

    By:AdamAug 4, 2017
    Staff Member Moderator

    Aug 21, 2014
    Likes Received:
    Hi everyone

    This is just a super super quick set of docs on how to use the modular vehicle scripts in 10p7 (they're in earlier ones, but I'd recommend upgrading, as there has been a ton of new features and fixes added in this version):

    Quick note: we'll be adding proper documentation and tutorials via YouTube and the wiki soon. This is just temporary docs to help you get started if you want to play with them now.

    Version Note: This will need a 0.8 viewer to work with all these features. I expect one to come out early next week. It should work in the editor and preview tools now however.

    Grab 10p7 from this thread here. (Make sure to read the instructions if you're upgrading!)

    The component name is 'Modular Vehicle'

    Modular Vehicles
    Modular vehicles are basically built from a collection of modules. A vehicle can have more than one set of modules attached - if you want to make a carboat then you can, using both the wheels and the boat (and other) physics.

    The following are the fields available:

    Animation Settings (Simple):
    - Seat Root:
    this is a position where the root of the avatar will be placed (typically the centre of the avatar at feet height). Use it to easily offset your animations and control where the avatar appears.
    - Ride Animation: this is a animation which will play on the player when they are riding the vehicle. It should be a looped, humanoid animation clip.

    General Properties:
    - Mass:
    this is the density of your vehicle. The sum of the area of the attached colliders, multiplied by the mass is the total mass of the vehicle in the physics system. Typically around 1500 is optimal. (The unit is undefined, but I suspect it's close to kg/m³) - this pipes into the rigidbody mass field at runtime. Heavier is often better.

    - Center of Gravity Offset: This offsets your vehicles center of gravity - the lower you move it, the more stable the vehicle will be (to a certain limit.) Y-1 is often good, but tweak it until you're happy.

    Animation (Complex)
    - Player Animator:
    coming soon, will allow you to swap a custom character controller onto a player avatar for powerful animations than just a simple clip (above).

    Locomotion Settings
    Core Forces

    Stability Correction
    - Upright:
    Tick to force an upright angular motion - if the angle (in Dot product units) is more than this from pointing directly upright, it will try twist the car upright. Useful in somewhat unstable vehicles in keeping them in the playable orientation.
    - Upright Dot: The dot product angle, -1.0 = 180', 1.0 = 0' - approximately. (i.e. 0.3 = if it's tilted more than about ~60', begin correcting)
    - Upright Force: the amount of force (torque) used to flip the vehicle back upright.

    Upright correction should only be used if you need it. It will interfere with standard operation of vehicles in some cases (i.e. going down hills).

    Constant Forces
    - Constant Local:
    Is there a constant force (unit: newtons) on the local axis?
    - Local Force: the forces for the above.
    - Constant World: Is there a constant force (unit: newtons) on the world axis? (useful for counteracting or strengthening gravity)
    - World Force: the forces for the above.

    Input Controlled Forces
    - Forward/Backward/Left/Right/Strafe Left/Strafe Right/Up/Down:
    If the users key is pressed down (i.e. WASDECQE) - the corresponding force on the local axes will be applied. Z is usually forward, so for Forward, you may want (0,0,10), and Backward (0,0,-5)

    Note: This force cheats. It is useful for some types of vehicles (e.g. scifi hover vehicles) which don't use typical locomotion methods; but for cars, and ground objects, I'd recommend using Wheels and similar.

    - Braking Force: This damps the vehicle by velocity until zero when the spacebar is pushed. As per above, this force cheats, and the other methods of braking are more realistic.

    - Speed Controlled Forces: These forces apply based on your current speed magnitude. Useful for airplanes where 'lift' is often somewhat proportional to speed. (Note: more forces for airplanes are on the agenda).

    - Rotate X/Y/Z:
    If ticked, rotational energy will be applied (units: torque is in newton-meters) based on the keyboard or controller inputs. E.g. X spins by vertical axis, Y by horizontal, Z by strafe axis (q/e).

    Wind Zone Forces:
    - Still to be implemented - apply forces from nearby wind zones to this object. (Useful for sailboats, coming soon.)

    Add up to 20 wheels to a vehicle, each has a bunch of settings.

    Visual Transform: The object which will be rotated/moved with the wheel.
    Wheel Collider: A unity physics 'Wheel Collider' to be used for this wheel, has a bunch of settings which are covered in the Unity documentation.

    Motor Power:
    This applies torque to the motor if the corresponding key is pressed. For convenience, the backwards torque is reversed automatically (so you can use positive number units). Typically for a vehicle with mass of 1500, and average vehicle size, the torque values should be between 400 and 4000. Note that the faster the vehicle, the harder it will be to control and the more easily it might blow out. Specified in newton-meters.

    Holding spacebar will engage this brake with the applied torque. Recommend 1000+ values for this (5000 is good). Braking Torque should be stronger than Forward torque.

    Idle Braking:
    This will apply a brake when no keys are pressed. Good to stop vehicles rolling off randomly. Suggest 100-1000, but up to you.

    Will use the horizontal axis (A/D) to steer the vehicle. The wheel will rotate by the angle specified. It will move towards that rotation at 'Steer Turn Speed' degrees per second. Suggested values: Min/Max Angle: -15, 15. Turn Speed: 50 to 70.

    Skid Effects:
    Skid Threshold:
    how much friction has to be applied to the wheel before skid effects engage. 0.1 to 2.0 is typical.
    Skid Particles: a particle system to emit skid particles from (i.e. burning tire smoke), will be emitted at point of contact with the ground.
    Skid Particle Amount: How many particles to emit every N seconds while skidding. 1-2 is a good value.
    Skid Time Between emission: how often particles emit (see above), 0.02 is a good value.
    Skid Trail: if a trail renderer is slotted in here, it will be enabled while skidding (i.e. tire tracks)
    Skid Sound: a audiosource to enable while skidding (loops are suggested, but not mandatory).
    Skid Sound Volume: the volume to maximally set the skid sound to
    Skid Sound Velocity: how quickly the volume will move up/down (i.e. 2.0 = 0.5 seconds to go from 0 to 1)

    Suspension Sounds:
    Suspension Bounce Sound:
    will play when this wheel connects with the ground after 'Suspension Air Minimum Time' in the air.

    Hover Points
    This is used for flying 'hover' style vehicles such as futuristic craft and helicopters.

    Contact Point: where we will try cast to the ground from (well, specified in Force Direction, typically the ground.)
    Ray Distance: how far we will search for the ground - should typically be the range which within the craft is optimally hovering.
    Force at Distances: this lets you control how much force is applied to the vehicle to keep it afloat. You'll need to experiment with this a bit to get some optimal values, but it should typically be mass (actual mass, not density above) multiplied by gravity (9.81m/s)
    Force Direction: which way should this hover point aim - typically you want 0, -1, 0 for 'down'. World space tickbox indicates whether this should be local, or world units.

    Boat Forces
    Buoyancy - this controls buoyancy for bots. Typically make a big box collider covering the hull of your vehicle, and tick it on. Fairly straight forward.

    These two curves control how the object will recieve drag at certain forward velocities. When the object is moving at a certain speed (X axis on curve editor), it will have drag equal to the Y value on the curve. Higher values at higher speeds allow the object to be easier to control at velocity, enforce a speed limit, and prevent the object exploding on the slightly collision (i.e. a bump on the ground) that would typically happen in the real world if you drove that fast into something. Velocity typically should peak at about 0.15 at 20-80m/s. (X axis is in meters per second). Angular drag should be high. 2+ when faster than 20m/s.

    Engine Noises
    Engine Sound will play when moving, at a pitch equal to the pitch curve. Start sound will play when the user hops into the vehicle, and stop sound will play when the user exits.

    If specified, the selected CineMachine camera(s) will be activated when the user gets into the car (by default, upload your vehicles with the components ticked off so they are not enabled.). See CineMachine docs on this.

    These four events will fire at varying stages. OnActivate and OnDeactive occur when the vehicle starts/stops - for all players (inc. player). OnPlayerActivate/Deactivate will only trigger when the client PC starts/stops the vehicle (good for hiding/showing GUIs and HUDs)
    James Stallings and Lex4art like this.
  2. Adam

    By:AdamAug 4, 2017
    Staff Member Moderator

    Aug 21, 2014
    Likes Received:
    And for good measure, here's some screenshots of the setup of my test car. This one drives fairly well.





    ZareShadows and AshaSekayi like this.