Use curve to better orientate checkpoints along the track

soundtrack
Ensar Sarajčić 2021-11-20 17:04:57 +01:00
parent d947b3e11e
commit 9d1ddac430
1 changed files with 7 additions and 5 deletions

View File

@ -32,14 +32,16 @@ func _ready() -> void:
for _checkpoint_number in range(checkpoint_count):
var new_checkpoint: Area = Area.new()
new_checkpoint.add_child(_build_checkpoint_collision())
new_checkpoint.transform.origin = path.curve.interpolate_baked(section)
new_checkpoint.look_at_from_position(
checkpoints.to_global(path.curve.interpolate_baked(section)),
checkpoints.to_global(path.curve.interpolate_baked(section + 0.01)),
path.curve.interpolate_baked_up_vector(section)
)
section += section_size
checkpoints.add_child(new_checkpoint)
if GlobalSettings.debug:
var mesh = CylinderMesh.new()
mesh.top_radius = checkpoint_dim.y
mesh.bottom_radius = checkpoint_dim.y
mesh.height = checkpoint_dim.x
var mesh = CubeMesh.new()
mesh.size = Vector3(checkpoint_dim.x, checkpoint_dim.y, 5)
if debug_material != null:
mesh.material = debug_material
var meshinst = MeshInstance.new()