Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody
- var speed = 15.0
- var jump_str = 25.0
- var gravity = 50.0
- var vel = Vector3.ZERO
- var snap_vect = Vector3.DOWN
- var dir = Vector3.ZERO
- onready var _spr_arm = $SpringArm
- onready var _model = $woman#$girl
- var is_spinning = false
- var spin_angle = 0
- var look_angle = 0
- var look_dir = Vector2()
- func _physics_process(delta):
- dir = Vector3.ZERO
- dir.x = Input.get_action_strength("D") - Input.get_action_strength("A")
- dir.z = Input.get_action_strength("S") - Input.get_action_strength("W")
- dir = dir.rotated(Vector3.UP, _spr_arm.rotation.y).normalized()
- vel.x = dir.x * speed
- vel.z = dir.z * speed
- vel.y -= gravity * delta
- # Jump
- var just_landed = is_on_floor() and snap_vect == Vector3.ZERO
- var is_jumping = is_on_floor() and Input.is_action_just_pressed("JUMP")
- if is_jumping:
- vel.y = jump_str
- snap_vect = Vector3.ZERO
- elif just_landed:
- snap_vect = Vector3.DOWN
- vel = move_and_slide_with_snap(vel, snap_vect, Vector3.UP, true, 4, deg2rad(89))
- # Animations & Facing Direction
- if vel.length() > 0.2:
- if not (vel.z == 0 and vel.x == 0):
- if not is_spinning:
- gravity = 50.0
- speed = 15.0
- look_dir = Vector2(vel.z, vel.x)
- _model.rotation.y = look_dir.angle()
- if is_on_floor():
- is_spinning = false
- _model.get_node("AnimationPlayer").playback_speed = 5
- _model.get_node("AnimationPlayer").play("Run")
- else:
- _model.get_node("AnimationPlayer").play("Jump")
- if is_spinning:
- _model.rotation.y += 50 * delta
- else:
- gravity = 25.0
- speed = 30.0
- _model.rotation.y += 50 * delta
- _model.get_node("AnimationPlayer").play("0TPose")
- if is_on_floor():
- is_spinning = false
- gravity = 30.0
- speed = 25.0
- _model.get_node("AnimationPlayer").playback_speed = 5
- _model.get_node("AnimationPlayer").play("Run")
- else:
- _model.get_node("AnimationPlayer").play("Jump")
- if is_spinning:
- _model.rotation.y += 50 * delta
- else:
- is_spinning = false
- gravity = 50.0
- speed = 15.0
- else:
- is_spinning = false
- gravity = 50.0
- speed = 15.0
- if is_on_floor():
- _model.get_node("AnimationPlayer").playback_speed = 1
- _model.get_node("AnimationPlayer").play("Idle")
- else:
- _model.get_node("AnimationPlayer").play("Jump")
- if is_spinning:
- _model.rotation.y += 50 * delta
- if translation.y < 1.275 and is_spinning:
- translation.y = 1.275
- # warning-ignore:unused_argument
- func _process(delta):
- _spr_arm.translation = translation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement