A little problem i can't solve...

  1. a Ray shoots from a Ship, the end of the ray line is represented by the black cube

  2. Here’s how it looks from the game view, the black ray end can me rotated on Y (left, Right) Axis via mouse.

  3. The problem, when the ship is tilted (turning) and the ray is also going that direction , this happens

  4. the Ray end is on a lower level, than of the ship (ship Y position will always be 0 though, Ray end y position is 0 as well)

  5. here’s how it looks game view (Ship is tilted while turning, ray is moved to left)

One of the solutions i came up with is while turning only rotate the camera but not the ship, but before i have to do that i would like to see if there’s other workaround for this? (ray stays same level as ship) and i’am fairly new to unity so not sure what exactly i should do…

What exactly is the problem? What specifically is the difference between what’s happening, and what you would like to happen?

I want the end of the ray (black cube) to always be at the same level of the ship. currently when turning, the black cube goes at a lower Position as you can see from the picture.

also need to say the ray start & end are child of the ship.

here:

If you want to position the cube at right above the spot where the ray intersects the ground, then simply assign the y value of the ship to hit point, before assigning it to the cube.

Vector3 pos = hit.point;
pos.y = ship.transform.position.y;
cube.transform.position = pos;

I don’t think that’s what i meant,

if you made a cube, then another one as a child… then rotated main cube on X axis, the second one would go down, this is normal for Unity but i need a way for this not to happen, i think this is the problem in my case?

If you don’t want the second cube to rotate with the first, then you should simply not parent them that way. If you want the second cube to track the first one’s position but not rotation, then just add a script that, in LateUpdate(), copies the position of the thing it’s following (plus some offset) to its own position.

1 Like

I did other method, a Ray from screen to MousePosition, and another Ray from the ship to the End of the first ray… i don’t know if this is efficient or not but it seems to be fine for now

now when rotating the ship, the ray coming from the ship wouldn’t go on a lower level .

1 Like

Glad you found a solution. Not to hijack your thread, but can I ask how you did that cool, seemingly-infinite ground? Is it just a really big textured plane, or is there something more clever to it?

1 Like

haha, it’s just a texture on a plane

1 Like