#Vision cone with raycasts

1 messages · Page 1 of 1 (latest)

ashen viper
#

Hello! I've been trying to use a raycast system to make a vision cone for a mob i am making within a datapack. My raycasting system works perfectly fine at deteing when it hits a block vs when it hits an entity. My problem is that i want the raycast to detect entities in a radius around the ray, not just where the ray hits. Can anyone help me with that. Optionally. if it's possible to actually make it a "cone" (narrower near the entity and the radius getting progressively higher), i would be grateful.

patent lagoon
#

An actual cone with accurste hit detection is nearly impossible.

You have to make some compromises

ashen viper
#

i see

#

one problem i had is that i managed to gen a "cylinde", but it started hitting entities through walls too

patent lagoon
#
  1. Use a distance selector that increases in size every step of the raycast.
#
  1. Use the dx, dy, and dz selector arguments for accurate hit detection but in a square shape
ashen viper
#

i tried doing this, but it only worked in one way: for instance, it was testing around the ray but only on its right side, not left

patent lagoon
#
  1. every step of the raycast, shoot 8 rays away from the current position of the original raycast and every step shoot those rays a bit further.
#
  1. Shoot 1 ray from the center, like normal and then shoot more rays from the same origin but with a slight angle.
ashen viper
patent lagoon
ashen viper
#

and i think the 4th option would suit best honestly, but idk what i did wrong

patent lagoon
ashen viper
#

i messed a lot with the original code now, but i could show you the same exact raycast code i used for a different creation if it helps

#

this is a raycast i did for a magic staff for a different map

#

but i used the same logic for the vision cone

patent lagoon
#

The only thing you have to do for the cone to work is to add a rotation argument to the first images first command and copy it as many times as you need rays.

#

You can also make it shoot out of the eyey exactly with the anchor subcommand

ashen viper
#

hmm, i'll have to look into that, since i am not fully experienced with those

#

i am not an expert in commands, i just have some knowledge haha

#

and for the roation argument part

#

i basically need to add one separate command with a different rotation for each individual ray?

#

i mean, copy paste the first command from the first pic, but with a different rotation each time

patent lagoon
#

yes

ashen viper
#

alright, i see

#

thanks for the help! if i have more difficulties, i'll come by again and ask