progress2
This commit is contained in:
parent
db7474043b
commit
3d4c75ddab
|
@ -8,4 +8,8 @@ CMKY: https://www.shadertoy.com/view/MltBW4
|
||||||
Fresnel: https://godotshaders.com/snippet/fresnel/
|
Fresnel: https://godotshaders.com/snippet/fresnel/
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
occlussion shader: https://www.reddit.com/r/godot/comments/rww6e9/comment/hrfa51g/?utm_source=share&utm_medium=web2x&context=3
|
occlussion shader: https://www.reddit.com/r/godot/comments/rww6e9/comment/hrfa51g/?utm_source=share&utm_medium=web2x&context=3
|
||||||
|
|
||||||
|
|
||||||
|
Sound:
|
||||||
|
billiard-clack: https://freesound.org/people/Za-Games/sounds/539854/
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://c5v6c6x05lqg3"
|
||||||
|
path="res://.godot/imported/billiard-clack.wav-3f99ec74be11d1cb465d3dc06a94b10f.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://audio/billiard-clack.wav"
|
||||||
|
dest_files=["res://.godot/imported/billiard-clack.wav-3f99ec74be11d1cb465d3dc06a94b10f.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=0
|
|
@ -4,7 +4,8 @@ extends Node3D
|
||||||
@export var initial_target: Node3D
|
@export var initial_target: Node3D
|
||||||
var target: Targetable = null
|
var target: Targetable = null
|
||||||
@export var sensitivity := 0.01
|
@export var sensitivity := 0.01
|
||||||
@export var charge_time := 2
|
@export var charge_time := 1.7
|
||||||
|
@export var min_charge := 0.2
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_target(initial_target)
|
set_target(initial_target)
|
||||||
|
@ -13,26 +14,53 @@ func get_charge():
|
||||||
return %radial_ui.charge_amount
|
return %radial_ui.charge_amount
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
|
var billiard := target.get_billiard()
|
||||||
if event is InputEventMouseMotion and MouseControl.mouse_is_locked() and get_charge() == 0.0:
|
if event is InputEventMouseMotion and MouseControl.mouse_is_locked() and get_charge() == 0.0:
|
||||||
rotate_view(event.relative*sensitivity)
|
rotate_view(event.relative*sensitivity)
|
||||||
if event.is_action("charge"):
|
if event.is_action_released("charge") and not billiard.can_hit and charge_tween != null:
|
||||||
|
release()
|
||||||
|
if event.is_action_pressed("charge") and billiard.can_hit and charge_tween == null:
|
||||||
charge(event.get_action_strength("charge"))
|
charge(event.get_action_strength("charge"))
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
transform.origin = target.global_position
|
transform.origin = target.global_position
|
||||||
camera.global_position = %camera_spot.global_position
|
camera.global_position = %camera_spot.global_position
|
||||||
camera.look_at(target.global_position)
|
camera.look_at(target.global_position)
|
||||||
|
if get_charge() >= 1.0:
|
||||||
|
cancel_charge()
|
||||||
|
|
||||||
var charge_tween: Tween = null
|
func cancel_charge():
|
||||||
func charge(amount: float):
|
%radial_ui.set_charge(0.0)
|
||||||
|
%ChargeSound.stop()
|
||||||
if charge_tween != null:
|
if charge_tween != null:
|
||||||
charge_tween.kill()
|
charge_tween.kill()
|
||||||
if amount == 0.0:
|
charge_tween = null
|
||||||
%radial_ui.set_charge(0.0)
|
var billiard := target.get_billiard()
|
||||||
$AudioStreamPlayer.stop()
|
billiard.can_hit = true
|
||||||
|
|
||||||
|
func release():
|
||||||
|
if get_charge() <= min_charge:
|
||||||
|
cancel_charge()
|
||||||
return
|
return
|
||||||
|
%ChargeReleaseSound.volume_db = get_charge() * 12
|
||||||
|
%ChargeReleaseSound.play()
|
||||||
|
var billiard := target.get_billiard()
|
||||||
|
billiard.hit((target.global_position - %camera_spot.global_position).normalized())
|
||||||
|
%radial_ui.set_charge(0.0)
|
||||||
|
%ChargeSound.stop()
|
||||||
|
if charge_tween != null:
|
||||||
|
charge_tween.kill()
|
||||||
|
charge_tween = null
|
||||||
|
|
||||||
|
var charge_tween: Tween = null
|
||||||
|
func charge(_amount: float):
|
||||||
|
var billiard := target.get_billiard()
|
||||||
|
billiard.can_hit = false
|
||||||
|
if charge_tween != null:
|
||||||
|
charge_tween.kill()
|
||||||
charge_tween = create_tween()
|
charge_tween = create_tween()
|
||||||
charge_tween.tween_method(%radial_ui.set_charge, 0.0, 1.0, charge_time)
|
charge_tween.tween_method(%radial_ui.set_charge, 0.0, 1.0, charge_time)
|
||||||
$AudioStreamPlayer.play()
|
%ChargeSound.play()
|
||||||
|
|
||||||
func rotate_view(amount: Vector2):
|
func rotate_view(amount: Vector2):
|
||||||
rotate_y(-amount.x)
|
rotate_y(-amount.x)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://drmb4sitb74fx"]
|
[gd_scene load_steps=5 format=3 uid="uid://drmb4sitb74fx"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://control_scheme/controller.gd" id="1_h3pjb"]
|
[ext_resource type="Script" path="res://control_scheme/controller.gd" id="1_h3pjb"]
|
||||||
[ext_resource type="PackedScene" uid="uid://p2n48c8st55d" path="res://control_scheme/radial_ui.tscn" id="2_qidcb"]
|
[ext_resource type="PackedScene" uid="uid://p2n48c8st55d" path="res://control_scheme/radial_ui.tscn" id="2_qidcb"]
|
||||||
[ext_resource type="AudioStream" uid="uid://ckhf7ksthi053" path="res://audio/charge.wav" id="3_exgm6"]
|
[ext_resource type="AudioStream" uid="uid://ckhf7ksthi053" path="res://audio/charge.wav" id="3_exgm6"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://c5v6c6x05lqg3" path="res://audio/billiard-clack.wav" id="4_12r5s"]
|
||||||
|
|
||||||
[node name="controller" type="Node3D"]
|
[node name="controller" type="Node3D"]
|
||||||
top_level = true
|
top_level = true
|
||||||
|
@ -18,5 +19,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0)
|
||||||
[node name="radial_ui" parent="." instance=ExtResource("2_qidcb")]
|
[node name="radial_ui" parent="." instance=ExtResource("2_qidcb")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
||||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
[node name="ChargeSound" type="AudioStreamPlayer" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("3_exgm6")
|
stream = ExtResource("3_exgm6")
|
||||||
|
|
||||||
|
[node name="ChargeReleaseSound" type="AudioStreamPlayer" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
stream = ExtResource("4_12r5s")
|
||||||
|
|
|
@ -6,6 +6,9 @@ class_name Targetable
|
||||||
static func is_targetable(node: Node3D) -> Targetable:
|
static func is_targetable(node: Node3D) -> Targetable:
|
||||||
return node.get_node_or_null("is_targetable")
|
return node.get_node_or_null("is_targetable")
|
||||||
|
|
||||||
|
func get_billiard() -> Billiard:
|
||||||
|
return get_parent()
|
||||||
|
|
||||||
func make_target():
|
func make_target():
|
||||||
walk_meshes_post_order(self.get_parent(), change_all_materials)
|
walk_meshes_post_order(self.get_parent(), change_all_materials)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ _subresources={
|
||||||
"PATH:grape2": {
|
"PATH:grape2": {
|
||||||
"generate/physics": true,
|
"generate/physics": true,
|
||||||
"physics/body_type": 1,
|
"physics/body_type": 1,
|
||||||
"physics/shape_type": 1
|
"physics/shape_type": 4,
|
||||||
|
"primitive/radius": 0.03
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,7 @@
|
||||||
extends RigidBody3D
|
extends RigidBody3D
|
||||||
|
class_name Billiard
|
||||||
|
|
||||||
|
var can_hit = true
|
||||||
|
|
||||||
|
func hit(impulse: Vector3):
|
||||||
|
apply_central_impulse(impulse)
|
||||||
|
|
|
@ -22,11 +22,10 @@ camera = NodePath("Camera3D")
|
||||||
initial_target = NodePath("../grape")
|
initial_target = NodePath("../grape")
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="controller" index="1"]
|
[node name="Camera3D" type="Camera3D" parent="controller" index="1"]
|
||||||
|
current = true
|
||||||
|
|
||||||
[node name="billiard" parent="." index="4" instance=ExtResource("3_gijly")]
|
[node name="grape" parent="." index="4" instance=ExtResource("3_gijly")]
|
||||||
|
|
||||||
[node name="grape" parent="." index="5" instance=ExtResource("3_gijly")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.56762, 0.385236)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.56762, 0.385236)
|
||||||
|
|
||||||
[node name="grape2" parent="." index="6" instance=ExtResource("3_gijly")]
|
[node name="grape2" parent="." index="5" instance=ExtResource("3_gijly")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.60495, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.60495, 0)
|
||||||
|
|
Loading…
Reference in New Issue