Changing Raycast origin upwards (offset)

Hello, I have an annoying problem and I seached everywhre but couldn’t find the solution.

I need t ochange the origin point of a raycast, I defined localOffset for it and I did exactly like all solutions that are supposed to work, but it is just not working:

All it does is change the direction of the ray, the origin however still stays at the origin of the game object (player character in this case, which is far too low).
So now the ray goes forward and up a bit.

I want to cast from about middle height (0.5).

var localOffset = transform.position + transform.up * 0.5;
var hitCollision : RaycastHit;
var CollisionCheckRange : int = 1.1;

if (Physics.Raycast (localOffset, transform.forward, hitCollision, CollisionCheckRange))


You should look up how Vectors work and the difference between global and local space. The origin of a Raycast is in global space, your localOffset is also in global space, therefore you have to convert your localOffset to global space, when you use it as global space. To do this, I suggest you use the Transform function called TransformPoint It transforms a point from local space to global space.

if (Physics.Raycast(transform.TransformPoint(localOffset), transform.forward/*... etc*/)) {

Hope this helps, Benproductions1