I know the ray function lets you set a length, and so does the camera.getForwardRay(*length*)
and so like the ray.origin line of code I though maybe a ray.end might be helpful.
I’m thinking of like doing the opposite of ray.origin.
with camera.getForwardRay you can specify the length, and so I thought a function the would find the end of the ray might be helpful in some cases.
Right now you can find the end of it by doing var length = 100; var ray = camera.getForwardRay(length); var endofray = new BABYLON.Vecor3(ray.direction.x*length, ray.direction.y*length, ray.direction.z*length);
I’ve had situations where I declare a vector then set it to a variable added and it effected the old one in other systems and situations.
Prolly does not need to be done, but I forget if BJS returns a new v3 on the add or not so I just do it to be safe. I know addInPlace does not… blah blah simple answer old habit.
@Givo yeah, I mean you can for simplicity when you control the page loading completely but on the playground Id recommend those.
yes, that game. I’ve been trying to switch over to rays since the ball mechanic of the old demo was wonky. You had to aim up to hit someone far away.
Now at the end of the ray a small “bullet” will spawn if you don’t hit anything. It will have a high mass and will fall. Kinda a weird way to do bullet-drop, but will make the game a bit easier.
I also want to find the coordinates of the end of the beam, but I don’t understand how the beam works if the direction is the same and the length is the same, but the rays are created differently? Aren’t these directions equal: BABYLON.Vector3(1, 0, -1) and BABYLON.Vector3(3, 0, -3) ?
Those both vectors would only be equals if normalized and as a best practice i try to always normalize any directions to prevent any unexpected behaviors