raycast not working

Hi,

I’m trying to run a raycast to check for a clear path between my ship and the enemy ship… Here’s the code:

main.lua local hits = mte.physics.rayCast(gameShips[1].x, gameShips[1].y, gameShips[2].x, gameShips[2].y, "fraction")

But it doesn’t seem to work - hits always returns 1 result, which appears to be the coordinates of gameShips[2] …

But I’m expecting to have ‘hits’ full of collisions with all the wall tiles between the two ships - all items have physics enabled, including the tilemap.

And gameShips[] are added to the mte sprite layer…

Could someone help with this?

Best wishes,

Carl

Hello Carl,

Sorry for the lateness of this reply.

“Fraction” is not a valid argument for physics.rayCast(). Try “sorted” or “unsorted”. 

Hello Carl,

Sorry for the lateness of this reply.

“Fraction” is not a valid argument for physics.rayCast(). Try “sorted” or “unsorted”.