reactivate gravity

This commit is contained in:
AleaJactaEst 2021-09-04 15:50:31 +02:00
parent a22e8db3fe
commit bfe71ec37c
2 changed files with 5 additions and 7 deletions

View file

@ -11,6 +11,7 @@
[node name="spatial" type="Spatial"] [node name="spatial" type="Spatial"]
[node name="player" parent="." instance=ExtResource( 8 )] [node name="player" parent="." instance=ExtResource( 8 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.01, 0 )
[node name="area_0_0" parent="." instance=ExtResource( 2 )] [node name="area_0_0" parent="." instance=ExtResource( 2 )]

View file

@ -107,12 +107,9 @@ func _process( delta ):
# Movement # Movement
velocity = self.calculate_velocity(velocity, move_direction, delta) velocity = self.calculate_velocity(velocity, move_direction, delta)
Config.msg_info("move_direction X:" + str(move_direction.x) + " Y:" + str(move_direction.y) + " Z:" + str(move_direction.z)) # Config.msg_info("move_direction X:" + str(move_direction.x) + " Y:" + str(move_direction.y) + " Z:" + str(move_direction.z))
Config.msg_info("velocity X:" + str(velocity.x) + " Y:" + str(velocity.y) + " Z:" + str(velocity.z)) # Config.msg_info("velocity X:" + str(velocity.x) + " Y:" + str(velocity.y) + " Z:" + str(velocity.z))
velocity = $creature.move_and_slide(velocity, Vector3.UP, true) velocity = $creature.move_and_slide(velocity, Vector3.UP, true)
# velocity = self.calculate_velocity(velocity, input_direction, delta)
#velocity = $creature.move_and_slide(velocity, Vector3.UP, true)
#Config.msg_info("X:" + str($creature.))
var pos : Vector3 = $creature.get_global_transform().origin var pos : Vector3 = $creature.get_global_transform().origin
Config.msg_info("pos X:" + str(pos.x) + " Y:" + str(pos.y) + " Z:" + str(pos.z)) Config.msg_info("pos X:" + str(pos.x) + " Y:" + str(pos.y) + " Z:" + str(pos.z))
@ -129,7 +126,7 @@ func calculate_velocity(
velocity_new *= $creature.move_speed velocity_new *= $creature.move_speed
if velocity_new.length() > $creature.max_speed: if velocity_new.length() > $creature.max_speed:
velocity_new = velocity_new.normalized() * $creature.max_speed velocity_new = velocity_new.normalized() * $creature.max_speed
#velocity_new.y = velocity_current.y + gravity * delta velocity_new.y = velocity_current.y + gravity * delta
return velocity_new return velocity_new