Recently, a coworker posed a question to me:
“How do you pass the player position to a material in UDK?”
“Well, couldn’t you just use the CameraWorldPosition node? The player and the camera are so close together the effect should be enough, right?” replied I.
“That could work, but I want to do a far-back third-person camera,” he countered.
“Oh…” I said.
After attempting a solution that was, admittedly, rather hacky involving trying to programmatically derive the location of the player based off a known distance between the camera and the player, I opted for something that could be considered hacky, but is as close to a programatic solution as an artist can get.
Looking into the situation, I thought perhaps I could use Kismet to pass the position of the player to a Material Instance using the Set VectorParam node… only to find out that node was taken offline back in 2010. Of course, with the clever use of “Append Vector” nodes, three scalar parameters can quickly turn into a float3, right?
Do excuse the garish colors. They were chosen to best showcase what’s happening. This could certainly be used to implement more subtle effects.
So that’s what I did. Here’s the base material (click to enlarge)
And the kismet setup. I put a delay after the operation is complete, otherwise Kismet throws a “too many operations” error. The delay is .033 seconds, or roughly 1 frame at 30 frames per second. The delay is barely perceptible, and it minimizes the number of calculations that have to happen. (click to enlarge)
Combining all that, you get this (video forthcoming):
From a CameraActor:
Also visible on my website: http://www.oztalay.com/matt/tutorials/player-position-based-material/