Skip to content

Commit

Permalink
Merge pull request #592 from aaronfranke/kine-char-3d-pos
Browse files Browse the repository at this point in the history
Set the reset position from the initial start position in KC3D
  • Loading branch information
aaronfranke authored Mar 3, 2021
2 parents 43d29bf + f91fe01 commit 35687c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions 3d/kinematic_character/player/cubio.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ const JUMP_SPEED = 5
const ACCELERATION = 2
const DECELERATION = 4

onready var camera = $Target/Camera
onready var gravity = -ProjectSettings.get_setting("physics/3d/default_gravity")
onready var start_position = translation
var velocity: Vector3

func _physics_process(delta):
if Input.is_action_just_pressed("exit"):
get_tree().quit()
if Input.is_action_just_pressed("reset_position"):
translation = Vector3(-3, 4, 8)
translation = start_position

var dir = Vector3()
dir.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
dir.z = Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")

# Get the camera's transform basis, but remove the X rotation such
# that the Y axis is up and Z is horizontal.
var cam_basis = $Target/Camera.global_transform.basis
var cam_basis = camera.global_transform.basis
var basis = cam_basis.rotated(cam_basis.x, -cam_basis.get_euler().x)
dir = basis.xform(dir)

Expand Down

0 comments on commit 35687c3

Please sign in to comment.