Updating FPS setting to lock to 30. Update cue to ball collision impulse calculations
This commit is contained in:
@@ -43,6 +43,8 @@ func cue_kick() -> void:
|
||||
animation_player.stop()
|
||||
animation_player.set_current_animation("RESET")
|
||||
|
||||
# NOTE: If 'set_speed_scale' set to a negative value, the animation
|
||||
# is played in reverse. If set to 0, the animation will not advance.
|
||||
animation_player.set_speed_scale(
|
||||
-1 / animation_player.get_current_animation_position()
|
||||
)
|
||||
|
||||
@@ -21,10 +21,13 @@ func rpc_input(event: String) -> void:
|
||||
if event == "aim_pulse":
|
||||
animation_player.play("aim_pulse")
|
||||
elif event == "aim_release":
|
||||
if animation_player.get_current_animation_position() < 0.2:
|
||||
animation_player.set_current_animation("RESET")
|
||||
return
|
||||
|
||||
# NOTE: Here, 'anim_pos' is used to gague strength of impulse
|
||||
pool_cue_tip.anim_pos = animation_player.get_current_animation_position()
|
||||
cue_shape.set_deferred("disabled", false)
|
||||
|
||||
cue_shape.disabled = false
|
||||
cue_kick()
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
|
||||
@@ -2,11 +2,11 @@ class_name PoolCueTip extends Area3D
|
||||
|
||||
|
||||
const MAX_CHARGE_TIME: float = 2.0
|
||||
const EFFECTIVE_CHARGE: float = 1.2
|
||||
const DEAD_TIME: float = 0.18 # seconds (tweak 0.1 – 0.18)
|
||||
const EFFECTIVE_CHARGE: float = 1.8
|
||||
const DEAD_TIME: float = 0.2
|
||||
|
||||
const MIN_FORCE: float = 0.03
|
||||
const MAX_FORCE: float = 1.4
|
||||
const MIN_FORCE: float = 0.2
|
||||
const MAX_FORCE: float = 2.0
|
||||
|
||||
var anim_pos: float = 0.0
|
||||
var impulse: Vector3 = Vector3.ZERO
|
||||
@@ -18,12 +18,12 @@ func _on_body_entered(body: Node) -> void:
|
||||
var usable = min(anim_pos - DEAD_TIME, EFFECTIVE_CHARGE)
|
||||
var time = usable / EFFECTIVE_CHARGE
|
||||
var direction = -global_transform.basis.z
|
||||
time = pow(time, 0.6)
|
||||
time = pow(time, 2)
|
||||
impulse = lerp(MIN_FORCE, MAX_FORCE, time) * direction
|
||||
|
||||
body.apply_impulse(
|
||||
impulse,
|
||||
body.global_position - $shape.global_position
|
||||
$shape.global_position - body.global_position
|
||||
)
|
||||
|
||||
#body.apply_central_impulse(impulse)
|
||||
|
||||
Reference in New Issue
Block a user