31
2018
Checking Last Known Good Position For A Car In The Track

Working on a small StuntCarRacer-inspired game with a friend.
Some note here about how to get car to return last known good position in the track.
Problems and Requirements
– Player gets stuck hanging in side of the track (1 or more tires hanging outside, cannot move)
– Player falls off from the track
– Should allow respawning into last known good position on the track
– Should reset player rotation towards correct direction
Solutions
- Trigger Checkpoints
- Everytime you enter a trigger, record this as a last good position
- Should work very nicely, but either need to manually place the triggers or have some logic to automatically do that, which could become difficult with complicated tracks
- You could manually place dummy objects in 3D modelling tool while making the track, to mark the trigger positions
- This would easily solve correct rotation (take from trigger forward)
- Take Closest Track Position
- Could raycast around the car to find closest track position and lift car to the track on that point
- Cannot be used, because if you fall of the track, driving in the ground is allowed (so you could take shortcuts then)
- Take Last Hit Point From Track
- Kind of works, but often that point could be already barely touching the track and player then falls off again
- Record Last Known Good Hit Point *Currently using this method
- Every few seconds:
- Check that every tire hits the track
- Check that every tire slope angle is below threshold (like 10° to avoid re-spawning in steep locations)
- Only issue is that correct rotation is difficult to get, if player was driving in wrong direction, he will be respawned towards that direction also
- Every few seconds:

Leave a comment
Recent posts
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
- [LudumDare57] Theme: Depths
- MotionVector Effect: Object “disappears” when paused
Recent Comments
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by











