Animations & Movement tweaks
This commit is contained in:
@ -1,9 +1,26 @@
|
||||
extends "res://Scripts/Component/Interactable.gd"
|
||||
|
||||
export var dialog_name : String = "unconfigured"
|
||||
export var face_right_init = true
|
||||
export var face_on_interact = true
|
||||
export var reset_after_dialog = false
|
||||
|
||||
func _ready():
|
||||
if $AnimationPlayer:
|
||||
$AnimationPlayer.play("Idle")
|
||||
$AnimationPlayer.seek(rand_range(0.0, 2.0), true)
|
||||
connect("interacted", self, "_on_interact")
|
||||
$Speaker.connect("dialog_exited", self, "_on_dialog_exit")
|
||||
if $Torso:
|
||||
$Torso.flip_h = face_right_init
|
||||
|
||||
func _on_interact():
|
||||
if $Torso:
|
||||
if face_on_interact:
|
||||
$Torso.flip_h = global_position.x < player.global_position.x
|
||||
$Speaker.start_dialog(dialog_name)
|
||||
|
||||
func _on_dialog_exit():
|
||||
if $Torso:
|
||||
if reset_after_dialog:
|
||||
$Torso.flip_h = face_right_init
|
||||
|
@ -7,7 +7,8 @@ func _ready():
|
||||
$Speaker.speaker_name = "Aura"
|
||||
connect("body_entered", self, "_on_body_enter")
|
||||
connect("body_exited", self, "_on_body_exit")
|
||||
#$Speaker.connect("dialog_exited", self, "_next")
|
||||
$AnimationPlayer.play("Idle")
|
||||
$AnimationPlayer.seek(rand_range(0.0,2.0))
|
||||
|
||||
func _on_body_enter(body):
|
||||
if body.has_method("add_interactable"):
|
||||
@ -16,7 +17,7 @@ func _on_body_enter(body):
|
||||
|
||||
func _process(delta):
|
||||
if state == 1 and not $Speaker.gui.is_in_dialog():
|
||||
$Sprite.frame = 0
|
||||
$AnimationPlayer.play("Shoot")
|
||||
$Speaker.start_dialog("aura_meeting_gun")
|
||||
state = 2
|
||||
elif state == 2 and not $Speaker.gui.is_in_dialog():
|
||||
|
@ -7,8 +7,11 @@ func _ready():
|
||||
$Speaker.speaker_name = "CEO Grant Blevins"
|
||||
$Speaker.speaker = "ceo"
|
||||
$Speaker.connect("dialog_exited", self, "_on_dialog_exit")
|
||||
$AnimationPlayer.play("Idle")
|
||||
$AnimationPlayer.seek(rand_range(0.0, 2.0), true)
|
||||
|
||||
func _on_interact():
|
||||
$Torso.flip_h = global_position.x < player.global_position.x
|
||||
if state == 0:
|
||||
$Speaker.start_dialog("intro_meet_ceo")
|
||||
if player:
|
||||
|
@ -4,6 +4,8 @@ export var start_on_play = true
|
||||
|
||||
func _ready():
|
||||
connect("interacted", self, "_on_interact")
|
||||
$AnimationPlayer.play("Idle")
|
||||
$AnimationPlayer.seek(rand_range(0.0, 2.0), true)
|
||||
$Speaker.speaker = "fast_talker"
|
||||
$Speaker.speaker_name = "Dr.Thadd"
|
||||
$Speaker.connect("dialog_exited", self, "give_tip")
|
||||
@ -12,6 +14,7 @@ func _ready():
|
||||
|
||||
func _on_interact():
|
||||
$Speaker.start_dialog("intro_science_followup")
|
||||
$Torso.flip_h = global_position.x < player.global_position.x
|
||||
|
||||
func give_tip():
|
||||
$Speaker.gui.display_tip("Used A & D to move\nleft and right")
|
||||
|
@ -3,13 +3,14 @@ extends KinematicBody2D
|
||||
export var clearance_level = 0
|
||||
|
||||
# Environment variables
|
||||
export var baseGravity : float = 9.8
|
||||
var baseGravity : float = 9.8
|
||||
|
||||
# Player movment variables
|
||||
export var maxMoveVelocity : float = 300
|
||||
export var moveAcceleration : float = 15
|
||||
export var moveFriction : float = 45
|
||||
export var jumpVelocity : float = -150
|
||||
var maxMoveVelocity : float = 150
|
||||
var moveAcceleration : float = 25
|
||||
var moveFriction : float = 65
|
||||
var jumpVelocity : float = -150
|
||||
var jumped = false
|
||||
|
||||
var moveMotion : float = 0 # Player Input ( <- & -> )
|
||||
var motion : Vector2 = Vector2(0,0) # Player's current velocity
|
||||
@ -25,7 +26,7 @@ func add_item(item):
|
||||
equip_item(item)
|
||||
|
||||
func equip_item(item):
|
||||
var node = get_node_or_null("Torso/RightArm/RightForearm/LeftHand/Node2D/" + item)
|
||||
var node = get_node_or_null("Sprite/Torso/RightArm/RightForearm/LeftHand/Node2D/" + item)
|
||||
if node:
|
||||
equiped = item
|
||||
node.show()
|
||||
@ -40,6 +41,7 @@ func remove_interactable(interactable):
|
||||
interactables.remove(loc)
|
||||
|
||||
func _physics_process(delta):
|
||||
jumped = false
|
||||
|
||||
# Gravity
|
||||
motion.y += baseGravity
|
||||
@ -67,8 +69,11 @@ func user_input():
|
||||
interactables[0].interact()
|
||||
|
||||
if is_on_floor() and Input.is_action_just_pressed("ui_up") and Input.is_action_pressed("ui_down"):
|
||||
position.y = position.y + 2
|
||||
return
|
||||
var test_pos = Vector2(position.x,position.y+5)
|
||||
|
||||
if not test_move(Transform2D(0,test_pos), Vector2(0,8)):
|
||||
position.y = position.y + 8
|
||||
return
|
||||
|
||||
if(Input.is_action_pressed("ui_left")):
|
||||
moveMotion -= moveAcceleration
|
||||
@ -77,6 +82,7 @@ func user_input():
|
||||
|
||||
if(is_on_floor() and Input.is_action_just_pressed("ui_up")):
|
||||
motion.y = jumpVelocity
|
||||
jumped = true
|
||||
|
||||
if is_on_floor() and (!Input.is_action_pressed("ui_left") and !Input.is_action_pressed("ui_right")):
|
||||
if moveMotion > 0:
|
||||
@ -86,12 +92,19 @@ func user_input():
|
||||
|
||||
func animation_manager(motion : float):
|
||||
|
||||
if moveMotion > 0:
|
||||
if not is_on_floor():
|
||||
$AnimationPlayer.play("InAir")
|
||||
elif jumped:
|
||||
if $AnimationPlayer.current_animation != "Jump":
|
||||
$AnimationPlayer.play("Jump")
|
||||
elif moveMotion > 0:
|
||||
$AnimationPlayer.playback_speed = abs(motion)/200
|
||||
$AnimationPlayer.play("RunRight")
|
||||
if $AnimationPlayer.current_animation != "RunRight":
|
||||
$AnimationPlayer.play("RunRight")
|
||||
elif moveMotion < 0:
|
||||
$AnimationPlayer.playback_speed = abs(motion)/200
|
||||
$AnimationPlayer.play("RunLeft")
|
||||
if $AnimationPlayer.current_animation != "RunLeft":
|
||||
$AnimationPlayer.play("RunLeft")
|
||||
else:
|
||||
$AnimationPlayer.playback_speed = 1
|
||||
$AnimationPlayer.play("Idle")
|
||||
|
Reference in New Issue
Block a user