Struggling with a simple Get_Collider problem, in 3D

Godot Version

4.5

Question

SO, I'm working on a really simple problem: I'm trying to make an enemy with a ShapeCast3D around it, where if the player walks into the enemy's aggro zone, the enemy starts to run towards the player. But I'm definitely struggling to make this code actually function.

The thing is, I’m so certain this is just about misplaced data types. But the more I stare at the manual, I can’t see the solution. the player variable was initially a CharacterBody3D, and the “move_toward” 2nd variation was player.position, because I thought get_collider(0) would return the first characterbody to enter the zone, and then the enemy would move towards that characterbody’s position. But I’m clearly way off. What am I doing wrong here?

Print what’s returned by get_collider() to see its type.

Thank you, actually. I forgot how to use “print” to check that stuff.

So I think I’m starting to see the problem here. It’s returning a CharacterBody3D, which is appropriate, and I now have that CharacterBody3D assigned to the player variable. Then when I do player.position, I would think that would be the appropriate “to” destination, because it would tell the NPC to move towards the Character Body’s x/y/z coordinates. But, is it just returning the data type? “CharacterBody3D?” It’s not actually identifying the specific body?

Work with global_position instead of position.

Btw. why do you call Vector3::move_toward() with 3 arguments when it requires only 2. Aslo, move_toward() is not in-place. You need to re-assign the value it returns.

Thanks for the help with this. Unfortunately this has all been part of me trying to solve a problem from an online lesson series and I’m clearly not at the point yet where I can properly trouble shoot this stuff so I’m going to throw in the towel for now and try to come back to this in a few weeks when I hopefully understand better how to parse error messages.