For some reason the rigidbodies in my game glitch around and phase through walls randomly? I'm pretty sure there's nothing in their code that would cause them to do this but I'll just post it here anyways
extends RigidBody3D
@export var carrying = false
var carrier : Node3D = null
@onready var offset = $CollisionShape3D
@onready var originalParent : Node
var carrySlotID : int = 0
func _ready() -> void:
originalParent = get_parent()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if(carrier != null && carrying):
position = Vector3(0,1 + offset.scale.y * carrySlotID,-0.5)
rotation = Vector3(0,0,0)
linear_velocity = Vector3(0,0,0)
if(Input.is_action_just_pressed("Drop")):
reparent(originalParent)
carrier.amountCarrying -= 1
carrying = false
carrier = null
var touchers = $Area3D.get_overlapping_areas()
for i in touchers:
_check_area(i)
func _check_area(area: Area3D) -> void:
if(area.is_in_group("Player") && area.get_parent().is_multiplayer_authority() && !carrying):
if(Input.is_action_just_pressed("Depositing")):
carrier = area.get_parent()
carrying = true
var modelPropNode = carrier.model.props
reparent(modelPropNode,false)
position = Vector3(0,1,-0.5)
carrySlotID = carrier.amountCarrying
carrier.amountCarrying += 1
print(carrier.amountCarrying)