Is there any way to constrict WorldToViewportPoint more?

Is there a way to make it so you need to look directly at a part, rather than it JUST being on screen? I have a mechanic that requires you to look at something or else you lose, but it’s too easy currently, I want to balance it better by making you have to look at it directly.

What’s directly? Do you want it so you have to have the part in the middle 50% of the screen?

Yeah, this is more what I’m describing, rather than it generally being on screen, more on if it’s in the middle.

Use this to convert the world position to a screen location and then you can measure it using screen coordinates: https://create.roblox.com/docs/reference/engine/classes/Camera#WorldToScreenPoint

So you could check 0.2 < X < 0.8 and 0.2 < y < 0.8 to make it more sensitive.

image
would this hypothetically work?

Yes but you can’t write it that way, I showed the comparison in a misleading way:

local x = plushModel.WhiteEyeHitbox.Position.X
local y = plushModel.WhiteEyeHitbox.Position.Y
local isOnScreen = x > 0.2 and x < 0.8 and y > 0.2 and y < 0.8

check the angle between the camera’s forward vector and the direction to the target. When that angle is sufficiently small, you consider the player to be “looking directly” at the object, making your mechanic more precise.

would this still work with WorldToViewportPoint? as it seems like this is just checking the position of the model

Yes, the X and Y should be from the result of that function, not the world position, my bad.

image
would it be like this?

errors out as Unable to cast bool to Vector3

i’m still really confused on what you mean, like am I using the WorldToScreenPoint to get the XY values and then doing something with the x > 0.2 etc?