how to cast rays in all direction from ray[1]?

Hello,

I’m lost here tried so much i cant get it to work properly, the rays all cast in a cone shape.

I am trying to cast rays to all 8 directions from the hit position of a ray.
but it seems it cast all rays in a cone shape to the origin of the game engine, i’m confused, why would it do that?

edit i have used the terrain/spawner orientation vectors as well with same results i thought lets try with simple x/y vectors

#edit oh boy stupid mistake, calculated the vectors on the wrong way got it working now.
manual vector creation


    vec_north       = ray[1] + Vector([0,1,0])
    vec_north_east  = ray[1] + Vector([1,1,0])
    vec_east        = ray[1] + Vector([1,0,0])
    vec_south_east  = ray[1] + Vector([1,-1,0])
    vec_south       = ray[1] + Vector([0,-1,0])
    vec_south_west  = ray[1] + Vector([-1,-1,0])
    vec_west        = ray[1] + Vector([-1,0,0])
    vec_north_west  = ray[1] + Vector([-1,1,0])
    
    render.drawLine(vec_north, ray[1], [1,0,0])
    render.drawLine(vec_north_east, ray[1], [1,0,0])
    render.drawLine(vec_east, ray[1], [1,0,0])
    render.drawLine(vec_south_east, ray[1], [1,0,0])
    render.drawLine(vec_south, ray[1], [1,0,0])
    render.drawLine(vec_south_west, ray[1], [1,0,0])
    render.drawLine(vec_west, ray[1], [1,0,0])
    render.drawLine(vec_north_west, ray[1], [1,0,0])

I do not think that is possible for my little brain…would it maybe easier to add a sphere at the hit location, count the verts and as they are indexed cast a ray from the hit point to the verts? The sphere does however reduce the casts to the number of verticies…or increase depending on your position on the subject…sphere casting would be good…
you could also add a sphere at the hitpoint with a colision sensor…and scale it up from the hit point…again…simple, but can get messy.
I assume you are trying to see if the object placed is near something…or in an open area…or maybe create sub-objects??

have you thought about using worldOrientation[x] but on all 3 axis and incrementing the orientations from -1 to 1?..
this would of course require 3 rayCasts…

I should download the file but I need to take my son to a swim class…I might be on later…sometimes it is simpler to use a simple and non complicated way to get things done…as per my example with a sphere…of course then you introduce a secondary object that may require it’s own script.

that would do, but is not the way i want it. im casting a ray so from that point casting other rays is easier.

ok, oldschool manual vector creation works.




    vec_north       = ray[1] + Vector([0,1,0])
    vec_north_east  = ray[1] + Vector([1,1,0])
    vec_east        = ray[1] + Vector([1,0,0])
    vec_south_east  = ray[1] + Vector([1,-1,0])
    vec_south       = ray[1] + Vector([0,-1,0])
    vec_south_west  = ray[1] + Vector([-1,-1,0])
    vec_west        = ray[1] + Vector([-1,0,0])
    vec_north_west  = ray[1] + Vector([-1,1,0])
    
    render.drawLine(vec_north, ray[1], [1,0,0])
    render.drawLine(vec_north_east, ray[1], [1,0,0])
    render.drawLine(vec_east, ray[1], [1,0,0])
    render.drawLine(vec_south_east, ray[1], [1,0,0])
    render.drawLine(vec_south, ray[1], [1,0,0])
    render.drawLine(vec_south_west, ray[1], [1,0,0])
    render.drawLine(vec_west, ray[1], [1,0,0])
    render.drawLine(vec_north_west, ray[1], [1,0,0])

ok, Glad you worked it out…just got home.