• Making a projected texture follow a player's eyeangles
    2 replies, posted
Sorry, this may be a stupid question. I've come back to Garry's Mod after several months of not touching it, and I think I still mostly know what I'm doing but I may have forgotten some stuff. I'm attempting to replace the default flashlight with a projected texture (env_projectedtexture). When the player hits their flashlight key, instead of turning on the HL2 light, it activates the projected texture which is parented to the player using it. Everything seems to work fine, except that the texture starts to become misaligned from the user's eyeangles when they look too far up or down. The first thing I tested was to add an offset of (0,0,64) so it would be at exact the position of the player's eyepos. This improved it, but did not completely alleviate the issue. Next I tried updating the projected texture's position and angles to copy the user's eyepos and eyeangles every tick, which does not appear to make any difference. Does anyone know how I can prevent this from happening in order to properly mimic the behavior of the default flashlight? I'm guessing I'm either forgetting something very basic, or there's some weird behavior with env_projectedtexture that I don't know about. https://i.imgur.com/O6tj6Bf.jpg
nvm, I totally forgot that the light would always inherit its parents position. Ended up parenting the env_projectedtexture to a entity that copies the user's eyepos and eyeangles.
Correct me if I'm wrong, I believe if you simply PT:SetAngles(EyeAngles), PT:SetPos(EyePos) and immediately PT:SetParent(Player) you won't need the middle entity
Sorry, you need to Log In to post a reply to this thread.