Added steering test

This commit is contained in:
Segey Lapin
2021-11-01 14:28:32 +03:00
parent daece19b55
commit aae5d0a8c3
2 changed files with 168 additions and 0 deletions

34
steering_test.gd Normal file
View File

@@ -0,0 +1,34 @@
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
var xdel = 16.0
var state = 0
func _process(delta):
var tgt = $target.global_transform.origin
var xt = $VehicleBody.global_transform.affine_inverse()
var loc = xt.xform(tgt)
$VehicleBody.steering = clamp(loc.x, -1, 1)
print(loc.x, " ", loc.z)
$Camera.look_at($VehicleBody.global_transform.origin, Vector3.UP)
match state:
0:
$VehicleBody.engine_force = 2000
state = 1
1:
xdel -= delta
if xdel < 0:
$VehicleBody.engine_force = 0