- Home /
Raycast from the wrong position.
This Ray should be casting from the position of this player so I cant figure out why this keeps happening. The picture isn't the worst I've seen either. Any reason why the ray is not starting from the players position.
var ray = Ray(transform.position,-gravityVector*30);
found = Physics.Raycast(ray,hit,30);
Debug.DrawRay(transform.position,-gravityVector*30);
I am just asking to make sure... the script is on the selected capsule from the picture?
I tested your code on the capsule and it works perfect. can you put a screenshot of the incpector window? displaying the capsule object and scrict component???
Answer by moghes · Aug 20, 2013 at 09:32 PM
to which object you have attached your script?
what is transform.position
Do a debug for transform.position, pause the game and check if your player's position is the same as you read in the console.
You can have a small sphere as a child to your player, remove the renderer component, and name your sphere "ray origin" or something (this is optional). Then attach your script to this sphere, and check if the ray comes out from it.
"You can have a small sphere as a child to your player, remove the renderer component, and name your sphere "ray origin" or something (this is optional). Then attach your script to this sphere, and check if the ray comes out from it." doesn't this make sense?
well sounds more like a test than a solution, but whatever.