0
Not a bug

Object pos - world pos not giving expected result

Brad Hammond 9 aastat tagasi uuendatud 9 aastat tagasi 9
I am trying to make a cube scale by offsetting the verts using Object pos - World pos to give me the direction from the part of the mesh to the centre of the object.
However it always gives me a direction toward world zero.

Any ideas?


Image 411

Vasta

Vasta
Not a bug
Just tried this, and it works fine here. Let me know if it still breaks for you!
(Note that you probably want Object Pos - World Pos, your current setup is reversed)
+1
Ülevaatamisel
Are the cubes flagged as static? In that case you'd get incorrect results, due to how batching works
90% sure they weren't.
I'll check when home. I can send a test project or the shader over if it helps.
Vasta
Not a bug
Just tried this, and it works fine here. Let me know if it still breaks for you!
(Note that you probably want Object Pos - World Pos, your current setup is reversed)
I just updated SF in case that was the issue.
Created a new shader from scratch and still the same issue. Can see it in the screenshot.
However there is a purple wire gizmo that is acting as expected in the scene. I haven't seen this gizmo that I remember.

Any ideas?

Link to the shader here



OK so now. Exact same shader. Made a new material and selected the shader. Now it works. Weird.

:) sorted
Actually I spoke too soon.

It works perfectly with one object. When you have multiple objects it scales from world zero.
Perhaps something to do with background batching ?
Yep. If I turn dynamic batching off it works fine.
Neat! You can also disable batching in the shader itself if you like :)
Oh sweet. I'll do that then :)