je sais pas trop
This commit is contained in:
25
script/benitier.gd
Normal file
25
script/benitier.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends Node3D
|
||||
|
||||
var in_player:bool = false
|
||||
var player: CharacterBody3D = null
|
||||
|
||||
# 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:
|
||||
if (in_player and Input.is_action_just_pressed("interact")):
|
||||
player.call("drink")
|
||||
|
||||
|
||||
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||
if (body is CharacterBody3D):
|
||||
in_player = true
|
||||
player = body
|
||||
|
||||
|
||||
func _on_area_3d_body_exited(body: Node3D) -> void:
|
||||
if (body is CharacterBody3D):
|
||||
in_player = false
|
||||
@@ -6,14 +6,16 @@ extends CharacterBody3D
|
||||
@export var SPEED_PARTICULES: float = 1;
|
||||
@export var checkpoint:Node3D = null
|
||||
@export var cooldown: float = 1
|
||||
@export var MAX_PARTICULES = 1000
|
||||
@export var MIN_PARTICULES = 50
|
||||
|
||||
@export_group("Children")
|
||||
@export var head: Node3D
|
||||
@export var anim: AnimationPlayer
|
||||
@export var particules: GPUParticles3D
|
||||
|
||||
@export var time_hand: float= 0
|
||||
|
||||
var time_hand: float= 0
|
||||
var nbr_particules = 1000
|
||||
|
||||
func _ready() -> void:
|
||||
time_hand = cooldown
|
||||
@@ -35,15 +37,18 @@ func _physics_process(delta: float) -> void:
|
||||
else:
|
||||
velocity += get_gravity() * delta * 3
|
||||
|
||||
if (Input.is_action_just_pressed("interact") and time_hand >= cooldown):
|
||||
if (Input.is_action_just_pressed("doigt") and time_hand >= cooldown):
|
||||
time_hand = 0
|
||||
var vect
|
||||
if(checkpoint == null):
|
||||
vect = Vector3.DOWN * SPEED_PARTICULES
|
||||
else:
|
||||
vect = (checkpoint.position - position).normalized() * SPEED_PARTICULES
|
||||
particules.amount = nbr_particules
|
||||
nbr_particules /= 2
|
||||
nbr_particules = clamp(nbr_particules, MIN_PARTICULES, MAX_PARTICULES)
|
||||
print(nbr_particules)
|
||||
particules.process_material.set("gravity", vect)
|
||||
|
||||
anim.play("finger")
|
||||
|
||||
var input_dir := Input.get_vector("left", "right", "up", "down")
|
||||
@@ -56,3 +61,6 @@ func _physics_process(delta: float) -> void:
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func drink() -> void:
|
||||
nbr_particules = MAX_PARTICULES
|
||||
|
||||
Reference in New Issue
Block a user