Passing a Object as a parameter

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

I’m fairly new to GDScript so I apologize if this is something super obvious that I’ve missed haha.

I’m basically working on a system where a player can mine a block. Each block has a Block script that has a function to “mine” itself. I’m wanting to call that from the players script when they presses a button but I can’t figure out a way to pass a object (being the block) as a parameter to a function. Can’t figure out as in I don’t know which variable I should be declaring the parameter as when writing the side function.

func MineBlock(direction : Vector2, block : Block <--- ?????):
if direction.x == -1:
	ChangeAnimation("Mine", true);
else:
	ChangeAnimation("Mine", false);

pass
:bust_in_silhouette: Reply From: gmaps

You have to check which type of node your block is - is it a MeshInstance, Spatial, etc… Click on the block and on the right side in inspector you will have the type of your node.
enter image description here
In this example, the type of block is Spatial.

Another way is if you add a script to your node (Block), first line of autogenerated content should be “extends ” and that is the parameter you should write there. But you can also omit that name since it’s only a hint - it’s not mandatory.