Skip to content

Commit 35687c3

Browse files
authored
Merge pull request #592 from aaronfranke/kine-char-3d-pos
Set the reset position from the initial start position in KC3D
2 parents 43d29bf + f91fe01 commit 35687c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

3d/kinematic_character/player/cubio.gd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@ const JUMP_SPEED = 5
55
const ACCELERATION = 2
66
const DECELERATION = 4
77

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

1113
func _physics_process(delta):
1214
if Input.is_action_just_pressed("exit"):
1315
get_tree().quit()
1416
if Input.is_action_just_pressed("reset_position"):
15-
translation = Vector3(-3, 4, 8)
17+
translation = start_position
1618

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

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

0 commit comments

Comments
 (0)