Non-local local position/direction?

Having some trouble with transform.localPosition. I was having trouble with my wall collision script and started debugging using rays to see what’s going on because it appeared like I would only collide with a single side of the wall. After some debugging I’ve found that my problem is that local isn’t local and I’m not sure why. What you can see in the attached picture is that my player (and every single other game object on screen) are children of a single empty GO with totally zeroed transform:


With this my floor collider works properly. But, if I rotate my parent empty GO 30° around Y to see where localPosition is, you can see where localPosition is here:

The debug ray in my character controller is simply Debug.DrawRay(transform.localPosition, desiredMove * 100, Color.cyan);. Why is my player’s localPosition located at the non-rotated position instead of following the parent’s rotation to the new location?

try adding transform.position to localpostion

Actually, nope. That still is quite off from my player’s location. Which now that I think through it again makes perfect sense, since transform.position is world coords, so should be exactly where the player is in the scene. When I draw the ray using transform.position it does start the ray at my player’s location as expected. But why would transform.localPosition not draw in exactly the same position, as I’m calling it in the context of a script on my player?

local/world position are very different.

Debug.DrawRay is drawing in world position and world rotation.

Hmm, so it doesn’t care about call context? Always world?