0
Completed

would it be possible to have a player and/or ai position via an object input node?

Marc 11 years ago updated by Freya Holmér (Developer) 11 years ago 3
it would be super great to have the location of the player or an AI as data in a shader.  In a few scripting tools I've used there's an object node that allows you to drop a target object from the scene.  That info could be awesome to do stuff like bending grass when a player walks over it.

Answer

Answer
Completed
Lionel Gallat answered this below :)
Joachim showed me that you can already do that: just create a "PlayerPos" Vector4 property in your shader and then create a script (which you'll put on the transform with the mesh/material). That script will feed the player position to the shader in an Update function like so:

objectMeshWithTheShader.renderer.material.SetVector("_PlayerPos", playerTransform.position);

That being said if there could be a way of directly accessing a transform node (drag and drop the node the same way you can a texture asset) and have access to its Position, Rotation and Scale that would be great. But again I'm not entirely sure that would be feasible or even if it's a good idea...
Answer
Completed
Lionel Gallat answered this below :)
Thanks for answering Lionel!
Thanks for the info Lionel.  I was thinking the same thing, but that sounds crazy at the same time.  But I guess it's not that crazy after all! :)  I'll give that a go.  Hopefully it will work if my mesh is being used on a terrain.

thanks again!