Fix division by zero error in platformer

This commit is contained in:
Juan Linietsky 2017-10-05 16:15:20 -03:00
parent ad8b0fbeb4
commit cdbb53c1c2
1 changed files with 3 additions and 1 deletions

View File

@ -120,7 +120,9 @@ func _physics_process(delta):
var mesh_xform = get_node("Armature").get_transform()
var facing_mesh = -mesh_xform.basis[0].normalized()
facing_mesh = (facing_mesh - up*facing_mesh.dot(up)).normalized()
facing_mesh = adjust_facing(facing_mesh, target_dir, delta, 1.0/hspeed*turn_speed, up)
if (hspeed>0):
facing_mesh = adjust_facing(facing_mesh, target_dir, delta, 1.0/hspeed*turn_speed, up)
var m3 = Basis(-facing_mesh, up, -facing_mesh.cross(up).normalized()).scaled(CHAR_SCALE)
get_node("Armature").set_transform(Transform(m3, mesh_xform.origin))