Trying another tutorial because I want to do a card game

Godot Version

4.7

Question

getting error: Invalid assignment of property or key ‘position’ with value of type ‘Vector2’ on a base object of type ‘Callable’.

I don’t see where I’ve deviated from base code. Here is code entered:

extends Node2D

var card_being_dragged

func _process(delta: float) -> void:
	if card_being_dragged:
		var mouse_pos = get_global_mouse_position()
		card_being_dragged.position = mouse_pos

func _input(event):
	if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
		if event.is_pressed():
			var card = _raycast_check_for_card()
			if card:
				card_being_dragged = card
			else: 
				card_being_dragged = null
func _raycast_check_for_card ():
	var space_state = get_world_2d().direct_space_state
	var parameters = PhysicsPointQueryParameters2D.new()
	parameters.position = get_global_mouse_position()
	parameters.collide_with_areas = true
	parameters.collision_mask = 1
	var result = space_state.intersect_point(parameters) 
	if result.size() > 0: 
		return result[0].collider.get_parent
	return null

func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.

What base code? You didn’t mention what tutorial or guide you’re following, so we have no idea what the “base” code is.

Also, what is “card_being_dragged”? Based on how you use it, it looks like a boolean, which doesn’t have a position property.
I highly recommend declaring what type your variables are, so you can avoid situations where it’s impossible to tell what your variable is supposed to be.

apologies for not including that.

Barry’s Dev Hell

See my edit above, try to do static typing.
It’s currently impossible to tell what type card_being_dragged is supposed to be.

card being dragged is a variable state, as far as I understand it. It’s based on the func raycast check for card

in raycast check for card, it gets the space state of the card and a new physics point query parameter 2d married to the mouse position. The mouse position interacts with the collision areas (boolean “parameters.collide_with_areas”) and parameters.collision_mask sets the active collision area. If the mouse position is over the card, and the collision level of the card is set to 1, the card will be detected (if I inderstand it right, which I probably don’t).

The func process governing card being dragged is supposed to tie the mouse position to the card position and change its state to “…being dragged” so that it follows the mouse.

In this video it works:

I tried to follow it step by step, but it doesn’t work for me like it does for him.

You are missing parantheses here, it should be .get_parent() at the end. Currently, your function does not return the parent Node, but the Callable get_parent.

Static typing will help you to easily spot those mistakes. For instance, if your function had a defined return type:

func _raycast_check_for_card() -> Node2D:

then Godot would give you an error on the exact line that tries to return a Callable.

Ok, thank you. I am very new and didn’t know what static typing is. I’ll try to use that from now on.