khanat-client/ressources/scripts/entity.gd

36 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

2020-03-21 09:10:26 +00:00
extends Spatial
var Creature = preload( "res://ressources/scripts/creatures_old.gd" )
2020-03-21 09:10:26 +00:00
export(bool) var gravity_enabled = true
var creature = null
var is_moving = false
#func _process( delta ):
# if self.gravity_enabled and $model:
# for child in $model.get_children():
# if child is KinematicBody:
# child.move_and_slide( Vector3( 0.0, -9.81, 0.0 ), Vector3( 0.0, 1.0, 0.0 ), true )
2020-03-21 09:10:26 +00:00
func move( m_movment ):
if $model:
for child in $model.get_children():
if child is KinematicBody:
var spatial = Spatial.new()
spatial.rotate( Vector3( 0.0, 1.0, 0.0 ), child.rotation.y )
spatial.translate( m_movment )
child.move_and_slide( spatial.translation*10.0, Vector3( 0.0, 1.0, 0.0 ), true )
spatial.queue_free()
2020-03-21 09:10:26 +00:00
func turn( m_rotation ):
if $model:
for child in $model.get_children():
if child is KinematicBody:
child.rotate_x( m_rotation.x )
child.rotate_y( m_rotation.y )
child.rotate_z( m_rotation.z )