Added steering test
This commit is contained in:
34
steering_test.gd
Normal file
34
steering_test.gd
Normal 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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user