playing with coin magnet
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=6 format=4 uid="uid://drmam18yg3du5"]
|
[gd_scene load_steps=7 format=4 uid="uid://drmam18yg3du5"]
|
||||||
|
|
||||||
[ext_resource type="Material" uid="uid://cuvfl1goud4at" path="res://Assets/Materials/GOLD.tres" id="1_2djid"]
|
[ext_resource type="Material" uid="uid://cuvfl1goud4at" path="res://Assets/Materials/GOLD.tres" id="1_2djid"]
|
||||||
|
[ext_resource type="Script" uid="uid://deq081gu1ort2" path="res://Scripts/gold.gd" id="1_b10cl"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_yxxlx"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_yxxlx"]
|
||||||
resource_name = "GOLD"
|
resource_name = "GOLD"
|
||||||
@@ -47,13 +48,15 @@ shadow_mesh = SubResource("ArrayMesh_hrwv8")
|
|||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_2djid"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_2djid"]
|
||||||
margin = 0.0
|
margin = 0.0
|
||||||
radius = 0.124843
|
radius = 0.0860376
|
||||||
|
|
||||||
[node name="GOLDCOIN" type="RigidBody3D"]
|
[node name="GOLDCOIN" type="RigidBody3D"]
|
||||||
collision_layer = 0
|
collision_layer = 32
|
||||||
|
collision_mask = 33
|
||||||
mass = 0.1
|
mass = 0.1
|
||||||
continuous_cd = true
|
continuous_cd = true
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
|
script = ExtResource("1_b10cl")
|
||||||
|
|
||||||
[node name="Cylinder" type="MeshInstance3D" parent="."]
|
[node name="Cylinder" type="MeshInstance3D" parent="."]
|
||||||
material_override = ExtResource("1_2djid")
|
material_override = ExtResource("1_2djid")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=13 format=3 uid="uid://bacgd5lmvaxea"]
|
[gd_scene load_steps=14 format=3 uid="uid://bacgd5lmvaxea"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bcgt64gerg8pv" path="res://Scripts/player.gd" id="1_5wxv7"]
|
[ext_resource type="Script" uid="uid://bcgt64gerg8pv" path="res://Scripts/player.gd" id="1_5wxv7"]
|
||||||
[ext_resource type="Material" uid="uid://b4rpp31c0dx2m" path="res://Assets/Materials/BasicMat.tres" id="1_y6xdh"]
|
[ext_resource type="Material" uid="uid://b4rpp31c0dx2m" path="res://Assets/Materials/BasicMat.tres" id="1_y6xdh"]
|
||||||
@@ -51,6 +51,9 @@ _data = {
|
|||||||
&"dodge": SubResource("Animation_hck1p")
|
&"dodge": SubResource("Animation_hck1p")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_juxdh"]
|
||||||
|
radius = 2.5
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D"]
|
[node name="Player" type="CharacterBody3D"]
|
||||||
script = ExtResource("1_5wxv7")
|
script = ExtResource("1_5wxv7")
|
||||||
|
|
||||||
@@ -98,3 +101,12 @@ shape = SubResource("CapsuleShape3D_y5hcb")
|
|||||||
libraries = {
|
libraries = {
|
||||||
&"": SubResource("AnimationLibrary_4qbli")
|
&"": SubResource("AnimationLibrary_4qbli")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Area3D" type="Area3D" parent="."]
|
||||||
|
collision_layer = 32
|
||||||
|
collision_mask = 32
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||||
|
shape = SubResource("SphereShape3D_juxdh")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="Area3D" to="." method="_on_area_3d_body_entered"]
|
||||||
|
|||||||
2
Scripts/gold.gd
Normal file
2
Scripts/gold.gd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
extends RigidBody3D
|
||||||
|
class_name Gold
|
||||||
1
Scripts/gold.gd.uid
Normal file
1
Scripts/gold.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://deq081gu1ort2
|
||||||
@@ -6,6 +6,9 @@ var dodge_direction
|
|||||||
@onready var body: MeshInstance3D = $Body
|
@onready var body: MeshInstance3D = $Body
|
||||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||||
|
|
||||||
|
var gold_to_vacuum = []
|
||||||
|
var current_gold
|
||||||
|
|
||||||
const MAX_STAMINA : float = 100
|
const MAX_STAMINA : float = 100
|
||||||
var stamina = MAX_STAMINA
|
var stamina = MAX_STAMINA
|
||||||
const STAMINA_REGEN_RATE = 10.0
|
const STAMINA_REGEN_RATE = 10.0
|
||||||
@@ -16,8 +19,26 @@ const DODGE_STAMINA_COST = 30.0
|
|||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
stamina_regen(delta)
|
stamina_regen(delta)
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
vacuum_found_gold()
|
||||||
|
|
||||||
func stamina_regen(delta):
|
func stamina_regen(delta):
|
||||||
if stamina < MAX_STAMINA:
|
if stamina < MAX_STAMINA:
|
||||||
print("STAMINA : ", stamina)
|
print("STAMINA : ", stamina)
|
||||||
stamina = clamp(stamina + delta * STAMINA_REGEN_RATE,0,MAX_STAMINA)
|
stamina = clamp(stamina + delta * STAMINA_REGEN_RATE,0,MAX_STAMINA)
|
||||||
|
|
||||||
|
func vacuum_found_gold():
|
||||||
|
if gold_to_vacuum.size() > 0:
|
||||||
|
for i in range(0,gold_to_vacuum.size()):
|
||||||
|
#var magnet_target
|
||||||
|
#if i == 0:
|
||||||
|
#magnet_target = self.global_position
|
||||||
|
#else:
|
||||||
|
#magnet_target = gold_to_vacuum[i-1].global_position
|
||||||
|
var direction_to_player = gold_to_vacuum[i].global_position.direction_to(self.global_position)
|
||||||
|
var distance_to_player = gold_to_vacuum[i].global_position.distance_to(self.global_position)
|
||||||
|
|
||||||
|
gold_to_vacuum[i].linear_velocity = direction_to_player * (5 + distance_to_player)
|
||||||
|
|
||||||
|
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||||
|
if body is Gold:
|
||||||
|
gold_to_vacuum.append(body)
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ scroll_down={
|
|||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_6="Objects"
|
||||||
3d_physics/layer_8="MouseTable"
|
3d_physics/layer_8="MouseTable"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|||||||
Reference in New Issue
Block a user