- Home /
Projector LookAt Player
I didn't want my player's blob shadow to look directly down at him, so I put the projector at the same position as the light and used LookAt to make it look more real, but it twitches out. It randomly looks downward.
var Player : Transform;
function FixedUpdate () {
transform.LookAt(Player);
}
The player makes particles and has a character controller. I don't know if those would effect any thing, because I'm new to Unity.
Answer by G-rant · Mar 12, 2012 at 12:41 AM
I turned on "Is Kinematic" on the Rigidbody Component to fix it.
Answer by Kleptomaniac · Mar 11, 2012 at 04:21 AM
I believe your problem is that you have put this in FixedUpdate (). FixedUpdate is framerate independent, as is explained here, and is called at fixed intervals as is defined at Edit > Project Settings > Time > Fixed Timestep. Its main purpose is for physics calculations, and unless it is absolutely necessary, should only ever be used for physics calculations.
In short, your LookAt is twitching because it is running at intervals independent of the framerate. In order to run every frame and in this case, you would instead use Update ().
Hope that helps, Klep
Thanks, but I originally had the code in the normal Update and not FixedUpdate, but I tried it again anyways, and it still didn't work. It seems to only happen to the player object(and it's child objects), but it works with the other objects. It is still looking at the player, but it looks downward on the x axis a little, but not strait down.
Hmm, I just tested this code and it works fine for me. The only aspects that were different were the fact that you are using a blob shadow projector and a rigidbody. Which raises the question, why are you using a rigidbody on your player? I presume that you are using the standard First Person Controller since you're using a Character Controller. Furthermore, why have you got it set to is$$anonymous$$inematic? I'm not sure if this would have an effect on the blob shadow projector, seeing as I've never used it, but perhaps some more information would be helpful.
$$anonymous$$lep
Putting it in Is $$anonymous$$inematic fixed the problem. I edited solved in the question name, but it didn't change.
You don't put "solved" in the question title, you accept the answer by using the checkmark. (Currently editing is broken and it takes changes quite a while to show up.)