Camera Fix
This commit is contained in:
parent
bde9492c63
commit
0ea4a45b06
26
Main.tscn
26
Main.tscn
|
|
@ -1,5 +1,7 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://src/classes/camera_guide.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/Camera2D.gd" type="Script" id=2]
|
||||
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://src/Main.gd" type="Script" id=7]
|
||||
[ext_resource path="res://src/ui/lobby.tscn" type="PackedScene" id=9]
|
||||
|
|
@ -17,6 +19,9 @@ void vertex() {
|
|||
shader = SubResource( 2 )
|
||||
shader_param/cam_offset = Vector2( 0, 0 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=4]
|
||||
extents = Vector2( 160, 90 )
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource( 7 )
|
||||
|
||||
|
|
@ -37,3 +42,22 @@ render_target_update_mode = 3
|
|||
[node name="Lobby" parent="ViewportContainer/Viewport" instance=ExtResource( 9 )]
|
||||
|
||||
[node name="SceneTransition" parent="ViewportContainer/Viewport" instance=ExtResource( 4 )]
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="ViewportContainer/Viewport"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2( 160, 90 )
|
||||
current = true
|
||||
script = ExtResource( 2 )
|
||||
tracking_node_path = NodePath("../CameraGuide")
|
||||
|
||||
[node name="CameraGuide" type="KinematicBody2D" parent="ViewportContainer/Viewport"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2( 160, 90 )
|
||||
collision_layer = 0
|
||||
collision_mask = 256
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/CameraGuide"]
|
||||
visible = false
|
||||
shape = SubResource( 4 )
|
||||
one_way_collision = true
|
||||
|
|
|
|||
|
|
@ -32,6 +32,5 @@ collision_mask = 256
|
|||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CameraGuide"]
|
||||
visible = false
|
||||
shape = SubResource( 1 )
|
||||
one_way_collision = true
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
[sub_resource type="Resource" id=3]
|
||||
resource_local_to_scene = true
|
||||
resource_name = "hurt"
|
||||
script = ExtResource( 18 )
|
||||
debug_state = false
|
||||
timeout_seconds = 2.0
|
||||
|
|
@ -50,7 +49,6 @@ jerk_factor = 0.0
|
|||
animation_sequence = [ "hurt" ]
|
||||
|
||||
[sub_resource type="Resource" id=4]
|
||||
resource_name = "move_0"
|
||||
script = ExtResource( 24 )
|
||||
state_name = "move"
|
||||
frame_number = 0
|
||||
|
|
@ -58,7 +56,6 @@ sound_effect_type = 0
|
|||
sound = ExtResource( 25 )
|
||||
|
||||
[sub_resource type="Resource" id=5]
|
||||
resource_name = "move_4"
|
||||
script = ExtResource( 24 )
|
||||
state_name = "move"
|
||||
frame_number = 4
|
||||
|
|
@ -66,7 +63,6 @@ sound_effect_type = 0
|
|||
sound = ExtResource( 25 )
|
||||
|
||||
[sub_resource type="Resource" id=6]
|
||||
resource_name = "land_0"
|
||||
script = ExtResource( 24 )
|
||||
state_name = "land"
|
||||
frame_number = 0
|
||||
|
|
|
|||
|
|
@ -29,40 +29,41 @@ func _physics_process(delta):
|
|||
#pos = lerp(pos, PlayerInfo.player_position, delta )
|
||||
var dir_to = Vector2(0,0)
|
||||
|
||||
var player_position = PlayerInfo.get_player_data(0).player_position
|
||||
if (PlayerInfo.get_player_data(0)):
|
||||
var player_position = PlayerInfo.get_player_data(0).player_position
|
||||
|
||||
# Calculate how far the player is from object
|
||||
var diff_to = (player_position - pos)
|
||||
var dist_to = (player_position - pos).length()
|
||||
|
||||
# Determine the chase direction of player is past the threshold
|
||||
# Try to prevent bounce
|
||||
if (is_on_wall() or is_on_floor() or is_on_ceiling()) and abs(diff_to.x) > 10:
|
||||
dir_to = pos.direction_to(player_position)
|
||||
elif !(is_on_wall() or is_on_floor() or is_on_ceiling()) and abs(diff_to.y) > 10:
|
||||
dir_to = pos.direction_to(player_position)
|
||||
# Calculate how far the player is from object
|
||||
var diff_to = (player_position - pos)
|
||||
var dist_to = (player_position - pos).length()
|
||||
|
||||
# Determine the chase direction of player is past the threshold
|
||||
# Try to prevent bounce
|
||||
if (is_on_wall() or is_on_floor() or is_on_ceiling()) and abs(diff_to.x) > 10:
|
||||
dir_to = pos.direction_to(player_position)
|
||||
elif !(is_on_wall() or is_on_floor() or is_on_ceiling()) and abs(diff_to.y) > 10:
|
||||
dir_to = pos.direction_to(player_position)
|
||||
|
||||
|
||||
# UiManager.debug_text = ( UiManager.debug_text +
|
||||
# # str(PlayerInfo.player_position.snapped(Vector2(0.01,0.01))) +
|
||||
# "\n" + str(is_on_ceiling()) + str(is_on_floor()) + str(is_on_wall()) +
|
||||
# "\nPP: {0}, {1}".format({"0":"%7.2f" % PlayerInfo.player_position.x, "1":"%7.2f" % PlayerInfo.player_position.y}) +
|
||||
# #"\nKB: " + str(global_position.snapped(Vector2(0.01,0.01))) +
|
||||
# "\nKB: {0}, {1}".format({"0":"%7.2f" % global_position.x, "1":"%7.2f" % global_position.y}) +
|
||||
# "\nDir to: {0}, {1}".format({"0":"%7.2f" % dir_to.x, "1":"%7.2f" % dir_to.y}) +
|
||||
# "\nPoint to: {0}, {1}".format({"0":"%7.2f" % diff_to.x, "1":"%7.2f" % diff_to.y})
|
||||
# #"\nDT: %7.2f" % dist_to
|
||||
# )
|
||||
|
||||
# UiManager.debug_text = ( UiManager.debug_text +
|
||||
# # str(PlayerInfo.player_position.snapped(Vector2(0.01,0.01))) +
|
||||
# "\n" + str(is_on_ceiling()) + str(is_on_floor()) + str(is_on_wall()) +
|
||||
# "\nPP: {0}, {1}".format({"0":"%7.2f" % PlayerInfo.player_position.x, "1":"%7.2f" % PlayerInfo.player_position.y}) +
|
||||
# #"\nKB: " + str(global_position.snapped(Vector2(0.01,0.01))) +
|
||||
# "\nKB: {0}, {1}".format({"0":"%7.2f" % global_position.x, "1":"%7.2f" % global_position.y}) +
|
||||
# "\nDir to: {0}, {1}".format({"0":"%7.2f" % dir_to.x, "1":"%7.2f" % dir_to.y}) +
|
||||
# "\nPoint to: {0}, {1}".format({"0":"%7.2f" % diff_to.x, "1":"%7.2f" % diff_to.y})
|
||||
# #"\nDT: %7.2f" % dist_to
|
||||
# )
|
||||
|
||||
# "Hi, {0} v{version}".format({0:"Godette", "version":"%0.2f" % 3.114})
|
||||
#"Hi, {0} v{1}".format(["Godette", "3.0"], "{_}")
|
||||
# "Hi, {0} v{version}".format({0:"Godette", "version":"%0.2f" % 3.114})
|
||||
#"Hi, {0} v{1}".format(["Godette", "3.0"], "{_}")
|
||||
|
||||
move_and_slide(dir_to * 180.0 )
|
||||
|
||||
# flip_tracker += delta
|
||||
# if flip_tracker < 10:
|
||||
# move_and_slide(Vector2(60.2,0))
|
||||
# elif flip_tracker < 20:
|
||||
# move_and_slide(Vector2(-60.2,0))
|
||||
# else:
|
||||
# flip_tracker = 0.0
|
||||
move_and_slide(dir_to * 180.0 )
|
||||
|
||||
# flip_tracker += delta
|
||||
# if flip_tracker < 10:
|
||||
# move_and_slide(Vector2(60.2,0))
|
||||
# elif flip_tracker < 20:
|
||||
# move_and_slide(Vector2(-60.2,0))
|
||||
# else:
|
||||
# flip_tracker = 0.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user