Still trying.
This commit is contained in:
parent
29ca00a8a0
commit
72f5fb64dc
|
|
@ -29,14 +29,12 @@ extents = Vector2( 160, 90 )
|
|||
|
||||
[node name="ViewportContainer" type="ViewportContainer" parent="."]
|
||||
material = SubResource( 3 )
|
||||
margin_left = -2.0
|
||||
margin_top = -2.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 180.0
|
||||
rect_scale = Vector2( 2, 2 )
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="ViewportContainer"]
|
||||
size = Vector2( 322, 182 )
|
||||
size = Vector2( 320, 180 )
|
||||
handle_input_locally = false
|
||||
render_target_update_mode = 3
|
||||
|
||||
|
|
|
|||
|
|
@ -19,14 +19,18 @@ func _ready():
|
|||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
#var tracking_pos = PlayerInfo.player_position
|
||||
var tracking_pos = _tracking_node.global_position
|
||||
# var tracking_pos = lerp(global_position, _tracking_node.global_position , 0.7)
|
||||
var tracking_pos = _tracking_node.global_position.round()
|
||||
|
||||
actual_cam_pos = lerp(position, tracking_pos, delta * 3)
|
||||
#position = actual_cam_pos.round()
|
||||
position = actual_cam_pos
|
||||
var cam_subpixel_pos = actual_cam_pos.round() - position
|
||||
# actual_cam_pos = lerp(actual_cam_pos, tracking_pos, delta * 5)
|
||||
actual_cam_pos = lerp(actual_cam_pos, tracking_pos, delta * 5)
|
||||
#position = actual_cam_pos
|
||||
var cam_subpixel_pos = actual_cam_pos.round() - actual_cam_pos
|
||||
|
||||
LevelInfo.viewport_container.material.set_shader_param("cam_offset", cam_subpixel_pos )
|
||||
# LevelInfo.viewport_container.material.set_shader_param("cam_offset", cam_subpixel_pos )
|
||||
|
||||
global_position = actual_cam_pos.round()
|
||||
|
||||
|
||||
UiManager.debug_text = ("SP: " + str(cam_subpixel_pos.snapped(Vector2(0.01,0.01))) +
|
||||
"\nCP: " + str (position.snapped(Vector2(0.01,0.01))) +
|
||||
|
|
@ -40,9 +44,11 @@ func _process(delta):
|
|||
# # Then substract half of the game size and add the player position
|
||||
#
|
||||
# var mouse_pos = _global.viewport.get_mouse_position() / window_scale - (game_size/2) + player.global_position
|
||||
# # Use another lerp to make the movement smooth
|
||||
# actual_cam_pos = lerp(actual_cam_pos, cam_pos, 5*delta)
|
||||
# # Using a lerp, the cameras position is moved towards the mouse position
|
||||
# var cam_pos = lerp( player.global_position, mouse_pos, 0.7)
|
||||
#
|
||||
# # Use another lerp to make the movement smooth
|
||||
# actual_cam_pos = lerp(actual_cam_pos, cam_pos, 5*delta)#
|
||||
# # Calculate the "subpixel" position of the new camera position
|
||||
# var cam_subpixel_pos = actual_cam_pos.round() - actual_cam_pos
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user