GetPoint is not a member of "boolean"

Don’t know what boolean is the console talkin’ about, but I have this in my code:

var ray = Physics.Raycast (playerCamera.transform.position, f7dir, f7Hit, 10000, 9);

Where, playerCamera, f7dir and f7Hit are defined before.

Than I have this:

var rayPoint = ray.GetPoint(10000);

And the console says:

“GetPoint” is not a member of “boolean”.
What boolean is it talking about and how do I fix it?

Physics.Raycast returns a boolean. It either hits or not. By assigning the return value of Physics.Raycast to “ray”, that makes “ray” a boolean. GetPoint can only be used with a ray, which you don’t have, but you can make one with playerCamera.transform.position and “f7dir”.

–Eric

Well, not exactly. The problem is that this is a weapon script and the weapon is not exactly accurate.
Here’s what I mean:

var f7dir = playerCamera.transform.TransformDirection (Random.Range(-50, 50), Random.Range(-50, 50), 1000);

And I’m making a bullet tracer effect:

var instantiatedTrayEffect = Instantiate(trayEffect, fireSpot.position, fireSpot.rotation);
instantiatedTrayEffect.transform.LookAt(f7Hit.point, Vector3.zero);

but the tray effect will get rotated correctly only if the ray hits something, so I need to get the end of the ray if it doesn’t hit anything. I tried to use f7dir, but this point is in some sort of a merge between local and world space, don’t know how the raycasting works with it, but using it to get the tray effect rotated to results in something pretty inaccurate

Take a look at the examples of how to use Physics.Raycast. It’ll show you the proper usage.

I can’t comment on the more intended behaviour that you’re trying to achieve, but gotta fix the code usage.

I’ve read this before (otherwise I wouldn’t know how to use raycasting), what have I done wrong that I need to fix? Everything seems normal. And by the way, I managed to fix the problem:

if(ray)…
else instantiatedTrayEffect.transform.LookAt(fireSpot.position + f7dir, Vector3.zero);