tweaked bullet and pick up method
This commit is contained in:
@@ -2,6 +2,7 @@ extends RigidBody3D
|
||||
|
||||
@export var broken_object : Resource
|
||||
|
||||
var break_on_land : bool = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -10,7 +11,8 @@ func _ready():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
if linear_velocity.length() >= 10:
|
||||
break_on_land = true
|
||||
|
||||
func breaking(current_velocity):
|
||||
var spawn_broken = broken_object.instantiate()
|
||||
@@ -23,3 +25,8 @@ func breaking(current_velocity):
|
||||
piece.linear_velocity += current_velocity
|
||||
get_tree().get_root().add_child(spawn_broken)
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_body_shape_entered(body_rid: RID, body: Node, body_shape_index: int, local_shape_index: int) -> void:
|
||||
if break_on_land:
|
||||
breaking(linear_velocity)
|
||||
|
||||
Reference in New Issue
Block a user