Testing collisionPolygon2D for Bridge for simplification of programming.
This commit is contained in:
parent
d8b4402926
commit
57b67e6d98
|
|
@ -60,3 +60,16 @@ func _on_animation_finished(_anim_name: StringName) -> void:
|
||||||
if _anim_name == _attack_animation_name:
|
if _anim_name == _attack_animation_name:
|
||||||
_can_attack = true
|
_can_attack = true
|
||||||
set_physics_process(true)
|
set_physics_process(true)
|
||||||
|
|
||||||
|
func update_collision_layer_mask(_type: String) -> void:
|
||||||
|
if _type == "in":
|
||||||
|
set_collision_layer_value(1, false)
|
||||||
|
set_collision_mask_value(1, false)
|
||||||
|
set_collision_layer_value(2, true)
|
||||||
|
set_collision_mask_value(2, true)
|
||||||
|
if _type == "out":
|
||||||
|
set_collision_layer_value(1, true)
|
||||||
|
set_collision_mask_value(1, true)
|
||||||
|
set_collision_layer_value(2, false)
|
||||||
|
set_collision_mask_value(2, false)
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
[ext_resource type="Script" uid="uid://cbuavletjs0kl" path="res://Factions/Knights/Troops/base_character.gd" id="1_jdal0"]
|
[ext_resource type="Script" uid="uid://cbuavletjs0kl" path="res://Factions/Knights/Troops/base_character.gd" id="1_jdal0"]
|
||||||
|
|
||||||
[node name="BaseCharacter" type="CharacterBody2D" node_paths=PackedStringArray("_animation", "_sprite2d")]
|
[node name="BaseCharacter" type="CharacterBody2D" node_paths=PackedStringArray("_animation", "_sprite2d")]
|
||||||
|
collision_layer = 9
|
||||||
|
collision_mask = 9
|
||||||
script = ExtResource("1_jdal0")
|
script = ExtResource("1_jdal0")
|
||||||
_animation = NodePath("Animation")
|
_animation = NodePath("Animation")
|
||||||
_sprite2d = NodePath("Texture")
|
_sprite2d = NodePath("Texture")
|
||||||
|
|
@ -13,4 +15,6 @@ _sprite2d = NodePath("Texture")
|
||||||
|
|
||||||
[node name="Animation" type="AnimationPlayer" parent="."]
|
[node name="Animation" type="AnimationPlayer" parent="."]
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
|
||||||
[connection signal="animation_finished" from="Animation" to="." method="_on_animation_finished"]
|
[connection signal="animation_finished" from="Animation" to="." method="_on_animation_finished"]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
extends Area2D
|
||||||
|
class_name BridgeArea
|
||||||
|
|
||||||
|
func _on_body_entered(_body: Node2D) -> void:
|
||||||
|
if _body is BaseCharacter:
|
||||||
|
_body.update_collision_layer_mask("in")
|
||||||
|
print("entered!")
|
||||||
|
|
||||||
|
func _on_body_exited(_body: Node2D) -> void:
|
||||||
|
if _body is BaseCharacter:
|
||||||
|
_body.update_collision_layer_mask("out")
|
||||||
|
print("exited!")
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dirg5mq4y4nk0
|
||||||
|
|
@ -8,4 +8,4 @@
|
||||||
[node name="TerrainManager" parent="." instance=ExtResource("1_8so7q")]
|
[node name="TerrainManager" parent="." instance=ExtResource("1_8so7q")]
|
||||||
|
|
||||||
[node name="Pawn" parent="." instance=ExtResource("2_debnr")]
|
[node name="Pawn" parent="." instance=ExtResource("2_debnr")]
|
||||||
position = Vector2(560, 400)
|
position = Vector2(1559, 839)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -17,8 +17,8 @@ config/icon="res://icon.svg"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=960
|
window/size/viewport_width=640
|
||||||
window/size/viewport_height=576
|
window/size/viewport_height=384
|
||||||
window/stretch/mode="canvas_items"
|
window/stretch/mode="canvas_items"
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue