How to get back physics when using call_deferred?

Godot Version



I keep getting this problem and have no clue how to fix it. Do I use set_deferred after everything?

What is the problem? What do you want to happen?

You have every item rotating towards the mouse with each input (often), then you move the look at into _on_player_entered so it only rotates once, when the player enters.

I only want to look_at mouse with the item on the player not all of them.

Maybe the easiest trick, since I do not have your player script, would be to only enable the _input processing once picked up. But doing look_ats on the player would be better, depends on how you intend to build out these items, try it out I guess :upside_down_face:

func _ready():
    # etc...

func _on_player_entered(body):
    if body.has_empty_slot():
        # etc...

That was a good idea, I tried to do that before just not on the player’s script but it still did not work. Here’s the players script if you see anything sweet if not thank you anyways.

extends CharacterBody2D

@onready var hand = $pivot/hand
@onready var fx = $pivot/FX
@onready var hotbar = $UI/Hotbar

func _ready():

func _physics_process(_delta):
	velocity = Input.get_vector("left","right","up","down") * 200
func play_FX(skill):
func add_item(stats,skill):
func has_empty_slot():
	return find_child("Weapons").is_available()

This is the item script. I tried the set_process_input on both item and player

extends Sprite2D

@onready var collision = $Area2D/CollisionShape2D
@export var stats : Item
@export var skill : Skill

func _ready():
	if stats != null:
		texture = stats.icon
func _on_player_entered(body):
	if body.has_empty_slot():
		position = body.position

given these two scripts set_process_input will do nothing, it only disables a func _input(event): override. Neither script has one, but in the video the Item did.

1 Like

lol I didn’t even see that. Thank you that actually works perfect.