generated from krampus/template-godot4
Player can cancel meters in shot setup
This commit is contained in:
parent
9337a63b69
commit
e1a07fac86
|
@ -4,6 +4,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://btntjs7mbdigu" path="res://assets/textures/gfolfball/gfolfball_normal.png" id="2_mx7l6"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_2gatw"]
|
||||
friction = 0.2
|
||||
bounce = 0.5
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xqofq"]
|
||||
|
|
|
@ -96,6 +96,8 @@ var _returning_free_camera := false
|
|||
|
||||
@onready var nice_animation: AnimationPlayer = %NiceAnimation
|
||||
|
||||
@onready var ball_impulse_debug: Node3D = %BallImpulseDebug
|
||||
|
||||
@onready var camera_distance := camera.position.z:
|
||||
set = _set_camera_distance
|
||||
|
||||
|
@ -145,11 +147,15 @@ func take_shot() -> void:
|
|||
print("Power: ", power_bar.value)
|
||||
print("Curve: ", curve_bar.value)
|
||||
|
||||
var impulse := shot_ref.global_basis * Vector3.ONE * base_power * power_bar.value
|
||||
var impulse := shot_ref.global_basis.z * base_power * power_bar.value
|
||||
print("Shot impulse: ", impulse)
|
||||
|
||||
ball_impulse_debug.transform = (
|
||||
Transform3D.IDENTITY.scaled(Vector3.ONE * impulse.length()).looking_at(impulse)
|
||||
)
|
||||
|
||||
physics_ball.freeze = false
|
||||
physics_ball.apply_central_impulse(impulse.rotated(Vector3.UP, -PI / 2.0))
|
||||
physics_ball.apply_central_impulse(impulse)
|
||||
|
||||
|
||||
func insert_free_cam() -> void:
|
||||
|
@ -224,7 +230,8 @@ func _on_club_change(new_club: T.Club) -> void:
|
|||
func _on_phase_change(new_phase: Phase) -> void:
|
||||
match new_phase:
|
||||
Phase.AIM:
|
||||
arrow_animation.play("show")
|
||||
if not arrow.visible:
|
||||
arrow_animation.play("show")
|
||||
camera.make_current()
|
||||
power_bar.hide()
|
||||
curve_bar.hide()
|
||||
|
@ -323,10 +330,16 @@ func _process(delta: float) -> void:
|
|||
if Input.is_action_just_pressed("shot_accept"):
|
||||
# TODO set power gauge parameters if needed
|
||||
power_animation.play("fill")
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
power_animation.stop()
|
||||
phase = Phase.AIM
|
||||
if Input.is_action_just_released("shot_accept") and power_bar.value > 0:
|
||||
power_animation.pause()
|
||||
phase = Phase.CURVE_ADJUST
|
||||
Phase.CURVE_ADJUST:
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
curve_animation.stop()
|
||||
phase = Phase.POWER_ADJUST
|
||||
if Input.is_action_just_pressed("shot_accept"):
|
||||
curve_animation.pause()
|
||||
phase = Phase.SHOT
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
[gd_scene load_steps=22 format=3 uid="uid://cy7t2tc4y3b4"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://cy7t2tc4y3b4"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/player/shot_setup/shot_setup.gd" id="1_r6ei4"]
|
||||
[ext_resource type="PackedScene" uid="uid://dfttci386ohip" path="res://src/player/physics_ball/physics_ball.tscn" id="2_1i5j5"]
|
||||
[ext_resource type="PackedScene" uid="uid://c2k88ns0h5ie1" path="res://src/ui/arrow.tscn" id="2_s70wl"]
|
||||
[ext_resource type="PackedScene" uid="uid://445qd7m4qe2j" path="res://src/player/shot_setup/club_selector/club_selector.tscn" id="4_56ape"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lnol1"]
|
||||
albedo_color = Color(0, 0.537255, 1, 1)
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_ql2ui"]
|
||||
material = SubResource("StandardMaterial3D_lnol1")
|
||||
top_radius = 0.02
|
||||
bottom_radius = 0.02
|
||||
height = 1.0
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_5uovl"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ug2a7"]
|
||||
|
@ -387,6 +396,15 @@ unique_name_in_owner = true
|
|||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)
|
||||
freeze = true
|
||||
|
||||
[node name="BallImpulseDebug" type="Node3D" parent="BallPoint"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="BallPoint/BallImpulseDebug"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -0.5)
|
||||
mesh = SubResource("CylinderMesh_ql2ui")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="PlayerPivot" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
|
@ -407,9 +425,18 @@ collision_mask = 0
|
|||
collide_with_bodies = false
|
||||
debug_shape_thickness = 4
|
||||
|
||||
[node name="WedgeRef" type="RayCast3D" parent="Direction"]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(-0.7, -5.29972e-08, 3.0598e-08, 0, 0.35, 0.606218, -6.11959e-08, 0.606218, -0.35, 0, 0.2, 0)
|
||||
enabled = false
|
||||
target_position = Vector3(0, 0, 1)
|
||||
collision_mask = 0
|
||||
collide_with_bodies = false
|
||||
debug_shape_thickness = 4
|
||||
|
||||
[node name="PuttRef" type="RayCast3D" parent="Direction"]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0.2, 0)
|
||||
transform = Transform3D(-1, 0, -1.50996e-07, 0, 1, 0, 1.50996e-07, 0, -1, 0, 0.2, 0)
|
||||
enabled = false
|
||||
target_position = Vector3(0, 0, 1)
|
||||
collision_mask = 0
|
||||
|
@ -600,4 +627,6 @@ offset_bottom = 50.0
|
|||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
|
||||
[node name="HUDAnimation" type="AnimationPlayer" parent="ShotUI"]
|
||||
|
||||
[connection signal="sleeping_state_changed" from="BallPoint/PhysicsBall" to="." method="_on_physics_ball_sleeping_state_changed"]
|
||||
|
|
Loading…
Reference in New Issue