Rudimentary turning and player detecting turret
This commit is contained in:
parent
1a45a0ca84
commit
71cf76e9ef
@ -10,14 +10,9 @@ onready var init_boost_type = player_state_machine.init_boost_type
|
||||
onready var camera_tween = $Camera2D/ShiftTween
|
||||
onready var camera = $Camera2D
|
||||
|
||||
# TODO Stuck to Wallslide on input
|
||||
# TODO Too much speed reduction on landings
|
||||
# TODO Too much speed through midair boosting
|
||||
# TODO Mini hopping through jump buffer(rare wallslide)
|
||||
# TODO Think about how each component and feature would scale in the future
|
||||
|
||||
|
||||
# TODO This is the worst thing since... you know
|
||||
# When the Enemy stomp AREA enters the enemy collision area -> stomp
|
||||
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group("weakpoint"):
|
||||
@ -128,7 +123,6 @@ func is_reversing_horizontal_movement(direction: Vector2) -> bool:
|
||||
# Returns if the character is touching a wall with its whole body
|
||||
# Being able to touch a vertical surface over this length also makes it a qualified "wall"
|
||||
# Also sets wall_touch_direction
|
||||
# TODO Walljumping sometimes catapults the player
|
||||
func is_touching_wall_completely() -> bool:
|
||||
for left_raycast in left_wall_raycasts.get_children():
|
||||
wall_touch_direction = -1
|
||||
@ -141,8 +135,6 @@ func is_touching_wall_completely() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
# TODO Player gets stuck to a wall easily
|
||||
# TODO Boosters should be able to fire while wallsliding
|
||||
# Attached to wall state is in the PlayerStateMachine
|
||||
func is_correct_walljump_input(direction: Vector2) -> bool:
|
||||
return (
|
||||
@ -247,7 +239,7 @@ func calculate_fall_velocity(
|
||||
func calculate_wallslide_velocity(
|
||||
linear_velocity: Vector2, delta: float, direction: Vector2
|
||||
) -> Vector2:
|
||||
# Walljump mechanicsdd
|
||||
# Walljump mechanics
|
||||
if is_correct_walljump_input(direction):
|
||||
linear_velocity.x = PhysicsFunc.two_step_euler(
|
||||
0, acceleration_force["walljump"].x * direction.x, mass, delta
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
[ext_resource path="res://src/Actors/Blobby/Blobby.gd" type="Script" id=4]
|
||||
[ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=5]
|
||||
|
||||
[node name="Blobby" type="KinematicBody2D"]
|
||||
[node name="Blobby" type="KinematicBody2D" groups=["player"]]
|
||||
collision_mask = 120
|
||||
script = ExtResource( 4 )
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ func _ready() -> void:
|
||||
velocity.x = -30
|
||||
|
||||
|
||||
# TODO Unify areas of kinematic bodies to skin
|
||||
# TODO adapt to groups
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||
return
|
||||
|
||||
19
src/Actors/Enemy/Turret.gd
Normal file
19
src/Actors/Enemy/Turret.gd
Normal file
@ -0,0 +1,19 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
onready var raycast: RayCast2D = $RayCast2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
$AnimationPlayer.play("Turret Rotation")
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if raycast.is_colliding():
|
||||
# The collider returns not the area or body it hit, but the parent of them
|
||||
if raycast.get_collider().is_in_group("player"):
|
||||
print_debug("player found")
|
||||
@ -1,13 +1,32 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/contraption/bumper.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/Actors/Enemy/Turret.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 108.869, 37.2448 )
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "Turret Rotation"
|
||||
length = 6.66
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 3.2 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0.0, 90.0 ]
|
||||
}
|
||||
|
||||
[node name="Turret" type="KinematicBody2D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 3
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
scale = Vector2( 0.612294, 1 )
|
||||
@ -19,5 +38,9 @@ shape = SubResource( 1 )
|
||||
|
||||
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||
enabled = true
|
||||
collision_mask = 0
|
||||
collide_with_bodies = false
|
||||
cast_to = Vector2( 0, 1e+07 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
pause_mode = 2
|
||||
playback_process_mode = 0
|
||||
"anims/Turret Rotation" = SubResource( 2 )
|
||||
|
||||
14
src/Actors/Enemy/TurretRayCast.gd
Normal file
14
src/Actors/Enemy/TurretRayCast.gd
Normal file
@ -0,0 +1,14 @@
|
||||
extends RayCast2D
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
|
||||
@ -23,7 +23,7 @@ var acceleration_force := {
|
||||
"walk": Vector2(2000, 68000),
|
||||
"idle": Vector2(2000, 68000),
|
||||
"run": Vector2(2000, 68000),
|
||||
"walljump": Vector2(50000, 58000),
|
||||
"walljump": Vector2(36000, 58000),
|
||||
"air_strafe": Vector2(20000, 0)
|
||||
}
|
||||
# Gravity as m/s^2
|
||||
|
||||
@ -27,7 +27,6 @@ tracks/0/keys = {
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="KinematicBody2D" type="KinematicBody2D" parent="."]
|
||||
position = Vector2( 19.2307, 0 )
|
||||
collision_layer = 8
|
||||
collision_mask = 0
|
||||
motion/sync_to_physics = true
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://assets/environment/blocks/Basic stone block.png" type="Texture" id=2]
|
||||
@ -7,6 +7,7 @@
|
||||
[ext_resource path="res://src/Contraptions/Platform/Track.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://src/HarmfulObjects/Bullet.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://src/Actors/Enemy/Turret.tscn" type="PackedScene" id=8]
|
||||
|
||||
[sub_resource type="NavigationPolygon" id=1]
|
||||
vertices = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )
|
||||
@ -79,7 +80,11 @@ scale = Vector2( 2.83999, 0.56 )
|
||||
position = Vector2( 8, 0 )
|
||||
|
||||
[node name="Bullet" parent="." instance=ExtResource( 6 )]
|
||||
position = Vector2( 237.856, 601.801 )
|
||||
position = Vector2( 901, 579 )
|
||||
|
||||
[node name="Turret" parent="." instance=ExtResource( 8 )]
|
||||
position = Vector2( 958.501, 464 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
|
||||
[editable path="Spring4"]
|
||||
[editable path="Track"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user