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
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on