Physics not in sync with script commands

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamepro5

A rigidbody projectile is supposed to be deleted when it hits the enemy. Instead, it starts to calculate and preform what it would do if it weren’t deleted, as in it starts to visibly bounce off the target. I don’t understand why this happens because the deletion happens in a single tick of the physics process function. Additionally, when aiming straight down, the projectile goes into the ground a little bit and then gets pushed back up. These two errors become more apparent the less powerful the platform is. I don’t know what is going on here and the Godot discord doesn’t seem to either.

This is my script for the projectile in question:

extends RigidBody

var weilder; #holds the player so the bullet remembers who shot it out

func instance_ready(): #custom function since using _ready would trigger before an instance has been created, during preload.
	translation = weilder.get_node("Head").global_transform.origin;
	rotation = weilder.get_node("Head").global_transform.basis.get_euler();
func _physics_process(delta):
	var bodies = get_colliding_bodies();
	if (bodies.size() != 0):
		var target = bodies[0];
		#get_node("explosive_pill").visible = false;
		if (target.get_filename() == "res://PlayerData/player.tscn"):
			#sleeping = true;
			#get_node("explosive_pill").visible = false;
			#self.get_node("CollisionShape").disabled = true;
			print("Hit detected @ ",, " @ time = ", OS.get_time()); -= 20;
			if ( <= 0):

Source code

Video of the issue

:bust_in_silhouette: Reply From: brainbug

from the docs:

Array get_colliding_bodies ( ) const

Returns a list of the bodies colliding with this one. Use contacts_reported to set the maximum number reported. You must also set contact_monitor to true.

Note: The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.

use Body_entered Signal !!

It works but the body entered signal does not detect when a player walks into the body while it’s laying on the ground.

Gamepro5 | 2020-06-27 22:33