#(Godot 3.5.1 | 2D) Detecting # of Tilemaps through a RayCast

7 messages · Page 1 of 1 (latest)

rough mango
#

I understand that there is something for this in Godot 4, but im at the point in my project where i would have to rebuild it from the ground up for godot 4, so instead im coming here to ask because i feel like there has to be a way to detect this in Godot 3.5.1

What i want for my enemy code is for them to shoot a raycast constantly at the player(which is done already), i want it to detect how many tiles are in the way from the enemy to the player, from there i can do some math with the return value to complete the code.

the primary issue is that i cant figure out how to detect the number of tiles that the raycast is going through, ive figured out everything else, its just this problem stopping me, how would i get the number of tiles that a raycast is passing through.

onyx plume
#

maybe not the best solution to it, but all I can think of right now is to divide the x value of the target position of the raycast by the size of a tile, same thing for the y value of the target position of the raycast

rough mango
#

thats not really what im looking for, what i want is for the game to look at this situation and tell me that, "the raycast goes through 2 tiles"

#

i should also mention that the player has a raycast too, the way i was looking when taking a screenshot makes it look like the enemys ray cast is messed up

onyx plume
#

then sorry, I don't know if there's an easy way to do it

rough mango
#

fair i guess

onyx plume
#

sounds quite specific I guess, so there's probably no easy way